# HG changeset patch # User Nicolas Dumazet # Date 1250962815 -7200 # Node ID 20ed9909dbd9251f76cacb463c480488eebf736b # Parent eae98607b3499385dd76e738a7379a409960be19 templatefilters: indent: do not compute text.endswith('\n') in each iteration diff -r eae98607b349 -r 20ed9909dbd9 mercurial/templatefilters.py --- a/mercurial/templatefilters.py Sat Aug 22 15:47:03 2009 +0200 +++ b/mercurial/templatefilters.py Sat Aug 22 19:40:15 2009 +0200 @@ -105,13 +105,14 @@ '''indent each non-empty line of text after first with prefix.''' lines = text.splitlines() num_lines = len(lines) + endswithnewline = text[-1:] == '\n' def indenter(): for i in xrange(num_lines): l = lines[i] if i and l.strip(): yield prefix yield l - if i < num_lines - 1 or text.endswith('\n'): + if i < num_lines - 1 or endswithnewline: yield '\n' return "".join(indenter())