From 12cae95c641bbd213080bdb3cf31cb5dec048c2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Wei=C3=9F?= Date: Sun, 6 May 2018 19:34:29 +0100 Subject: [PATCH] remove assertion that String.UTF8View doesn't underestimate count (#392) Motivation: I left an assertion that String.UTF8View's underestimatedCount is equal to the actual count of UTF-8 code units. It's good to see that it never failed so far so we can expect it to be really good which is important for performance. However, there's no problem if it does actually underestimate maybe for some special kind of Strings. So the assertion really isn't meaningful. Modifications: Remove the assertion. Result: Most likely nothing but we will not crash on something that we shouldn't crash on. --- Sources/NIO/ByteBuffer-core.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/Sources/NIO/ByteBuffer-core.swift b/Sources/NIO/ByteBuffer-core.swift index 0507cfc6c..327950596 100644 --- a/Sources/NIO/ByteBuffer-core.swift +++ b/Sources/NIO/ByteBuffer-core.swift @@ -386,7 +386,6 @@ public struct ByteBuffer { var (iterator, idx) = UnsafeMutableBufferPointer(start: base, count: underestimatedByteCount).initialize(from: bytes) assert(idx == underestimatedByteCount) while let b = iterator.next() { - assert(S.self != String.UTF8View.self) base = ensureCapacityAndReturnStorageBase(capacity: idx + 1) base[idx] = b idx += 1