Skip to content

Commit 5c25a8c

Browse files
committed
refactor(text): remove redundant truncate_pos assignments
Eliminates unnecessary variable initialization and update operations in truncation logic. The truncate_pos variable is only needed when the loop breaks due to width overflow, making the initial assignment and incremental updates redundant.
1 parent 5f4e9ee commit 5c25a8c

File tree

2 files changed

+0
-4
lines changed

2 files changed

+0
-4
lines changed

src/polykit/text/polytruncate.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,13 @@ def truncate_by_width(
190190

191191
# Find the truncation point
192192
current_width = 0.0
193-
truncate_pos = 0
194193

195194
for i, char in enumerate(text):
196195
char_width = cls.calculate_visual_width(char)
197196
if current_width + char_width > available_width:
198197
truncate_pos = i
199198
break
200199
current_width += char_width
201-
truncate_pos = i + 1
202200
else:
203201
# Text fits completely
204202
return text

src/polykit/text/truncate.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,13 @@ def truncate_by_width(
188188

189189
# Find the truncation point
190190
current_width = 0.0
191-
truncate_pos = 0
192191

193192
for i, char in enumerate(text):
194193
char_width = cls.calculate_visual_width(char)
195194
if current_width + char_width > available_width:
196195
truncate_pos = i
197196
break
198197
current_width += char_width
199-
truncate_pos = i + 1
200198
else:
201199
# Text fits completely
202200
return text

0 commit comments

Comments
 (0)