Skip to content

Commit 74035d7

Browse files
committed
Refactor
1 parent 4516438 commit 74035d7

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

curtsies/formatstring.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,11 @@ class ChunkSplitter:
203203
"""
204204

205205
def __init__(self, chunk: Chunk) -> None:
206+
self.reinit(chunk)
207+
208+
def reinit(self, chunk: Chunk) -> None:
209+
"""Reuse an existing Splitter instance for speed."""
210+
# TODO benchmark to prove this is worthwhile
206211
self.chunk = chunk
207212
self.internal_offset = 0 # index into chunk.s
208213
self.internal_width = 0 # width of chunks.s[:self.internal_offset]
@@ -211,11 +216,6 @@ def __init__(self, chunk: Chunk) -> None:
211216
divides.append(divides[-1] + wcwidth(c))
212217
self.divides = divides
213218

214-
def reinit(self, chunk: Chunk) -> None:
215-
"""Reuse an existing Splitter instance for speed."""
216-
# TODO benchmark to prove this is worthwhile
217-
self.__init__(chunk) # type: ignore
218-
219219
def request(self, max_width: int) -> Optional[Tuple[int, Chunk]]:
220220
"""Requests a sub-chunk of max_width or shorter. Returns None if no chunks left."""
221221
if max_width < 1:

0 commit comments

Comments
 (0)