summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-03-22 20:28:36 +0100
committerhut <hut@lavabit.com>2010-03-22 20:28:36 +0100
commit361781cddf95129746c8e311cd7d1c745baaa56c (patch)
tree92078d7d1180dea9b6f34b218884f350cba76bf2 /ranger
parentb712bbcf472326b8d748421bf2448acbfe0f92bf (diff)
downloadranger-361781cddf95129746c8e311cd7d1c745baaa56c.tar.gz
core.fm: use local variables in main loop for faster lookup
Diffstat (limited to 'ranger')
-rw-r--r--ranger/core/fm.py34
1 files changed, 21 insertions, 13 deletions
diff --git a/ranger/core/fm.py b/ranger/core/fm.py
index 121d70b3..d6822940 100644
--- a/ranger/core/fm.py
+++ b/ranger/core/fm.py
@@ -106,34 +106,42 @@ class FM(Actions):
 
 		gc_tick = 0
 
+		# for faster lookup:
+		ui = self.ui
+		throbber = ui.throbber
+		bookmarks = self.bookmarks
+		loader = self.loader
+		env = self.env
+		has_throbber = hasattr(ui, 'throbber')
+
 		try:
 			while True:
-				self.bookmarks.update_if_outdated()
-				self.loader.work()
-				if hasattr(self.ui, 'throbber'):
-					if self.loader.has_work():
-						self.ui.throbber(self.loader.status)
+				bookmarks.update_if_outdated()
+				loader.work()
+				if has_throbber:
+					if loader.has_work():
+						throbber(loader.status)
 					else:
-						self.ui.throbber(remove=True)
+						throbber(remove=True)
 
-				self.ui.redraw()
+				ui.redraw()
 
-				self.ui.set_load_mode(self.loader.has_work())
+				ui.set_load_mode(loader.has_work())
 
-				key = self.ui.get_next_key()
+				key = ui.get_next_key()
 
 				if key > 0:
 					if self.input_blocked and \
 							time() > self.input_blocked_until:
 						self.input_blocked = False
 					if not self.input_blocked:
-						self.ui.handle_key(key)
+						ui.handle_key(key)
 
 				gc_tick += 1
 				if gc_tick > TICKS_BEFORE_COLLECTING_GARBAGE:
 					gc_tick = 0
-					self.env.garbage_collect()
+					env.garbage_collect()
 
 		finally:
-			self.bookmarks.remember(self.env.cwd)
-			self.bookmarks.save()
+			bookmarks.remember(env.cwd)
+			bookmarks.save()