From 237a3babafecd94ed5e9765a5aa49cc9f8d73031 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Sun, 10 Mar 2019 18:54:32 +0000 Subject: [PATCH] core: more succinct iter_split(). --- mitogen/core.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mitogen/core.py b/mitogen/core.py index c1f5ea38..1507a2a3 100644 --- a/mitogen/core.py +++ b/mitogen/core.py @@ -621,15 +621,14 @@ def iter_split(buf, delim, func): `buf`, avoiding intermediate lists and quadratic string operations. Return the trailing undelimited portion of `buf`. """ + dlen = len(delim) start = 0 while True: nl = buf.find(delim, start) if nl == -1: - break + return buf[start:] func(buf[start:nl]) - start = nl + 1 - - return buf[start:] + start = nl + dlen class Py24Pickler(py_pickle.Pickler):