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()
it.com> 2009-12-15 12:28:00 +0100 cleanups, display link destinations' href='/akspecs/ranger/commit/ranger/colorschemes/jungle.py?id=30b2579508d921c6b5b2d9d6540126737b10d8b7'>30b25795 ^
cfdbb9d6 ^

779d21f4 ^












9adf06de ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75