Skip to content
Myr

Merge pull request #317 from shedokan/master

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Improved performance of filters.do_truncate()

authored by Armin Ronacher · committed by Armin Ronacher · parents 4f028a8, 10a10ad · Browse files · 1 file+5 added−10 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+5 added−10 removed

  • other:+5 added−10 removed

1 file+5 added−10 removed

modified:jinja2/filters.py+5 added-10 removed
475 unmodified lines
476 if len(s) <= (length + len(end)):477 return s478 elif killwords:479 return s[:length - len(end)] + end480 words = s.split(' ')481 result = []482 m = 0483 for word in words:484 m += len(word) + 1485 if m > (length - len(end)):486 break487 result.append(word)488 result.append(end)489 return u' '.join(result)480481 result = s[:length - len(end)].rsplit(' ', 1)[0]482 if len(result) < length:483 result += ' '484 return result + end485486@environmentfilter487def do_wordwrap(environment, s, width=79, break_long_words=True,488 wrapstring=None):489 """
506 unmodified lines