]> granicus.if.org Git - python/commitdiff
Faster implementation of normcase (using string.lower(
authorGuido van Rossum <guido@python.org>
Thu, 19 Feb 1998 21:08:36 +0000 (21:08 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 19 Feb 1998 21:08:36 +0000 (21:08 +0000)
string.replace(...)) instead of a for loop).

Don't call normcase() in normpath() -- the filesystem just might be
case preserving...

Lib/dospath.py

index e003db149fb4dcdf1e15986cdb563c746c69f74d..803ddb061edc7dc79b2959612506949bcd1e574d 100644 (file)
@@ -15,13 +15,7 @@ import string
 # possibly be added as a new function.
 
 def normcase(s):
-       res, s = splitdrive(s)
-       for c in s:
-               if c in '/\\':
-                       res = res + os.sep
-               else:
-                       res = res + c
-       return string.lower(res)
+       return string.lower(string.replace(s, "/", "\\"))
 
 
 # Return wheter a path is absolute.
@@ -316,7 +310,7 @@ def expandvars(path):
 # Also, components of the path are silently truncated to 8+3 notation.
 
 def normpath(path):
-       path = normcase(path)
+       path = string.replace(path, "/", "\\")
        prefix, path = splitdrive(path)
        while path[:1] == os.sep:
                prefix = prefix + os.sep