summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-03-28 17:33:11 +0200
committerhut <hut@lavabit.com>2010-03-28 17:33:11 +0200
commit385642efacc1e6946ee7e8f4415fa345e70388ec (patch)
tree30ee964940db6c6d68a13fda8aecb3380174219f
parentbb2a6b16fb80952f4e7228437f5edd19cf5586da (diff)
downloadranger-385642efacc1e6946ee7e8f4415fa345e70388ec.tar.gz
fsobject.directory: little optimization in sorting
1. no need to call path.basename.lower() since it's cached in
path.basename_lower.

2. no need to convert a bool to int for arithmetic operations

3. path.is_directory is faster than an isinstance() check
-rw-r--r--ranger/fsobject/directory.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/ranger/fsobject/directory.py b/ranger/fsobject/directory.py
index 3ef897e0..b0a93893 100644
--- a/ranger/fsobject/directory.py
+++ b/ranger/fsobject/directory.py
@@ -29,11 +29,11 @@ def sort_by_basename(path):
 
 def sort_by_basename_icase(path):
 	"""returns case-insensitive path.basename (for sorting)"""
-	return path.basename.lower()
+	return path.basename_lower
 
 def sort_by_directory(path):
 	"""returns 0 if path is a directory, otherwise 1 (for sorting)"""
-	return 1 - int( isinstance( path, Directory ) )
+	return 1 - path.is_directory
 
 class NoDirectoryGiven(Exception):
 	pass