From 4ca32ae23bad23b87595bff169cab9d9998a9e98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Sun, 14 May 2017 22:24:00 +0200 Subject: [PATCH] Avoid the slow path for end markers of size 2. --- stream/vibe/stream/operations.d | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/stream/vibe/stream/operations.d b/stream/vibe/stream/operations.d index 9b74462c64..4b9840a24c 100644 --- a/stream/vibe/stream/operations.d +++ b/stream/vibe/stream/operations.d @@ -392,8 +392,17 @@ private void readUntilSmall(R, InputStream)(InputStream stream, ref R dst, in ub stream.skip(pm.length); } else { dst.put(pm[0 .. idx]); - stream.skip(idx+1); - if (++nmatched == nmarker) return; + if (nmarker == 1) { + stream.skip(idx+1); + return; + } else if (idx+1 < pm.length && pm[idx+1] == marker[1]) { + assert(nmarker == 2); + stream.skip(idx+2); + return; + } else { + nmatched++; + stream.skip(idx+1); + } } } }