[pygccxml-commit] SF.net SVN: pygccxml: [465] pygccxml_dev/pygccxml/declarations/algorithm.py
Brought to you by:
mbaas,
roman_yakovenko
From: <al...@us...> - 2006-08-25 03:01:21
|
Revision: 465 Author: allenb Date: 2006-08-24 20:01:16 -0700 (Thu, 24 Aug 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=465&view=rev Log Message: ----------- - Track down performance killer in declaration_path method. This method is called so often that it eats up more time then anything else in my generation runs. This single change doubles the performance of pyplusplus for me. (713 seconds down to 356 seconds) Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/algorithm.py Modified: pygccxml_dev/pygccxml/declarations/algorithm.py =================================================================== --- pygccxml_dev/pygccxml/declarations/algorithm.py 2006-08-24 12:07:58 UTC (rev 464) +++ pygccxml_dev/pygccxml/declarations/algorithm.py 2006-08-25 03:01:16 UTC (rev 465) @@ -19,13 +19,18 @@ """ if not decl: return [] - result = [ decl.name ] - parent = decl.parent - while parent: - result.append( parent.name ) - parent = parent.parent - result.reverse() - return result + cached_decl_path = getattr(decl, "cached_decl_path", None) + if cached_decl_path: + return cached_decl_path + else: + result = [ decl.name ] + parent = decl.parent + while parent: + result.append( parent.name ) + parent = parent.parent + result.reverse() + setattr(decl, "cached_decl_path", result) + return result def full_name( decl ): """ @@ -74,7 +79,7 @@ decls.append( decl_or_decls ) answer = [] for decl in decls: - answer.extend( proceed_single( decl ) ) + answer.extend( proceed_single( decl ) ) return answer def __make_flatten_generator( decl_or_decls ): @@ -260,4 +265,4 @@ fname = 'visit_' + decl_inst.__class__.__name__[:-2] #removing '_t' from class name if not hasattr(visitor, fname ): raise visit_function_has_not_been_found_t( visitor, decl_inst ) - getattr( visitor, fname )() \ No newline at end of file + getattr( visitor, fname )() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |