From 032d0c439a2e4f2e80b3af69167820c3c6980017 Mon Sep 17 00:00:00 2001 From: Bob Farrell Date: Sat, 3 May 2008 00:51:55 +0100 Subject: [PATCH] Added a little optimisation to the new algo Not really going to make a huge difference but it wasn't exactly a great deal of work. --- bpython.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bpython.py b/bpython.py index 073e648..17e61b3 100644 --- a/bpython.py +++ b/bpython.py @@ -370,14 +370,14 @@ class Repl: down = ( y < h / 2 ) max_h = (h-y-2) if down else (y-2) optw = int(0.6 * w) - + self.lastmax = 0 items = [ i.rpartition('.')[-1] for i in items ] def calc_lsize(r): """Calculate the size required on screen to display the list.""" if items: - wl = max( len( i ) for i in items ) + 2 + wl = self.lastmax = max( (len( items[-1] ), self.lastmax) ) else: wl = 1 l = len( items ) @@ -404,6 +404,7 @@ class Repl: l = len(items) if topline and items: opth += 1 + if topline and not items: opth = 3