[PATCH 2/N] Remove unnecessary calls to normpath()
Jon Foster <[email protected]> Wed, 31 Mar 2010 12:51:31 +0100
| Newsgroups | gmane.comp.version-control.subversion.cvs2svn.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, SymbolTransform.transform() is called a lot - more than 40 million times in my "medium" test case[1]. os.path.normpath() does a fair amount of work, so we should avoid calling it unnecessarily in SymbolTransform.transform(). Kind regards, Jon [1] My test case is a subset of the real conversion I'm doing, this isn't an artificial stress test. ********************************************************************** This email and its attachments may be confidential and are intended solely for the use of the individual to whom it is addressed. Any views or opinions expressed are solely those of the author and do not necessarily represent those of Cabot Communications Ltd. If you are not the intended recipient of this email and its attachments, you must take no action based upon them, nor must you copy or show them to anyone. Cabot Communications Limited Verona House, Filwood Road, Bristol BS16 3RY, UK +44 (0) 1179584232 Co. Registered in England number 02817269 Please contact the sender if you believe you have received this email in error. ********************************************************************** ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ ------------------------------------------------------ http://cvs2svn.tigris.org/ds/viewMessage.do?dsForumId=1667&dsMessageId=2467671 To unsubscribe from this discussion, e-mail: [[email protected]].
cvs2svn_opt2_patch.txt
(text/plain, 1.6 KB)
Index: cvs2svn_lib/symbol_transform.py
===================================================================
--- cvs2svn_lib/symbol_transform.py (revision 5093)
+++ cvs2svn_lib/symbol_transform.py (working copy)
@@ -150,7 +150,9 @@
self._map[key] = new_name
def transform(self, cvs_file, symbol_name, revision):
- cvs_filename = os.path.normcase(os.path.normpath(cvs_file.filename))
+ # cvs_file.filename is guaranteed to already be normalised the way
+ # os.path.normpath() normalises paths. No need to call it again.
+ cvs_filename = os.path.normcase(cvs_file.filename)
return self._map.get(
(cvs_filename, symbol_name, revision), symbol_name
)
@@ -204,7 +206,9 @@
# No rules for that symbol name
return symbol_name
- cvs_path = os.path.normcase(os.path.normpath(cvs_file.filename))
+ # cvs_file.filename is guaranteed to already be normalised the way
+ # os.path.normpath() normalises paths. No need to call it again.
+ cvs_path = os.path.normcase(cvs_file.filename)
while True:
try:
return symbol_map[cvs_path]
@@ -250,7 +254,10 @@
self.__inner = inner_symbol_transform
def __does_rule_apply_to(self, cvs_file):
- cvs_path = os.path.normcase(os.path.normpath(cvs_file.filename))
+ # cvs_file.filename is guaranteed to already be normalised the way
+ # os.path.normpath() normalises paths. So we don't need to call
+ # os.path.normpath() again.
+ cvs_path = os.path.normcase(cvs_file.filename)
while cvs_path != self.__subtree:
new_cvs_path = os.path.dirname(cvs_path)
if new_cvs_path == cvs_path: