Revision: 1104
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1104&view=rev
Author: roman_yakovenko
Date: 2007-08-17 22:33:41 -0700 (Fri, 17 Aug 2007)
Log Message:
-----------
internal class impl optimization - in optiized mode it will reused the declarations list it has and will not create a new one
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/scopedef.py
Modified: pygccxml_dev/pygccxml/declarations/scopedef.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/scopedef.py 2007-08-18 05:31:20 UTC (rev 1103)
+++ pygccxml_dev/pygccxml/declarations/scopedef.py 2007-08-18 05:33:41 UTC (rev 1104)
@@ -75,6 +75,7 @@
self._type2decls_nr = {}
self._type2name2decls_nr = {}
self._all_decls = None
+ self._all_decls_not_recursive = None
def _get_logger( self ):
return utils.loggers.queries_engine
@@ -86,7 +87,12 @@
def _get__cmp__items(self):
"""implementation details"""
- items = [ self._sorted_list( self.declarations ) ]
+ items = []
+ if self._optimized:
+ #in this case we don't need to build class internal declarations list
+ items.append( self._sorted_list( self._all_decls_not_recursive ) )
+ else:
+ items.append( self._sorted_list( self.declarations ) )
items.extend( self._get__cmp__scope_items() )
return items
@@ -95,16 +101,24 @@
return False
return self._sorted_list( self.declarations[:] ) \
== other._sorted_list( other.declarations[:] )
+ #self_decls = self._all_decls_not_recursive
+ #if not self._optimized:
+ #self_decls = self._sorted_list( self.declarations[:] )
+ #other_decls = other._all_decls_not_recursive[:]
+ #if not other._optimized:
+ #other_decls = other._sorted_list( other.declarations[:] )
+ #else:
+ #return self_decls == other_decls
def _get_declarations_impl(self):
raise NotImplementedError()
-
+
def _get_declarations(self):
- return self._get_declarations_impl()
- declarations = property( _get_declarations,
- doc="""A list of children declarations.
- @type: list of L{declaration_t}
- """)
+ if True == self._optimized:
+ return self._all_decls_not_recursive
+ else:
+ return self._get_declarations_impl()
+ declarations = property( _get_declarations, doc="list of children L{declarations<declaration_t>}" )
def remove_declaration( self, decl ):
raise NotImplementedError()
@@ -136,6 +150,7 @@
self._type2decls_nr = {}
self._type2name2decls_nr = {}
self._all_decls = None
+ self._all_decls_not_recursive = None
map( lambda decl: decl.clear_optimizer()
, filter( lambda decl: isinstance( decl, scopedef_t )
@@ -165,7 +180,8 @@
self._type2name2decls[ dtype ] = {}
self._type2name2decls_nr[ dtype ] = {}
- self._all_decls = algorithm.make_flatten( self.declarations )
+ self._all_decls_not_recursive = self.declarations
+ self._all_decls = algorithm.make_flatten( self._all_decls_not_recursive )
for decl in self._all_decls:
types = self.__decl_types( decl )
for type_ in types:
@@ -182,7 +198,8 @@
name2decls_nr[ decl.name ].append( decl )
map( lambda decl: decl.init_optimizer()
- , filter( lambda decl: isinstance( decl, scopedef_t ), self.declarations ) )
+ , filter( lambda decl: isinstance( decl, scopedef_t )
+ , self._all_decls_not_recursive ) )
if self.name == '::':
self._logger.debug( "preparing data structures for query optimizer - done( %f seconds ). "
% ( time.clock() - start_time ) )
@@ -253,7 +270,6 @@
if matcher_args.has_key('allow_empty'):
del matcher_args['allow_empty']
-
matcher = match_class( **matcher_args )
if matcher.decl_type:
return matcher.decl_type
@@ -313,7 +329,7 @@
return self._all_decls
else:
self._logger.debug( 'non recursive query has not been optimized ( hint: query does not contain type and/or name )' )
- return self.declarations
+ return self._all_decls_not_recursive
def _find_single( self, match_class, **keywds ):
"""implementation details"""
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|