Skip to content

Commit 44f7c38

Browse files
committedMar 7, 2025··
project reader: try to simplify code
Align variable names Remove superfluous loops Regroup code
1 parent d1a2203 commit 44f7c38

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed
 

‎src/pygccxml/parser/project_reader.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -321,14 +321,9 @@ def __parse_file_by_file(self, files):
321321
self.logger.debug(
322322
"Cache has been flushed in %.1f secs",
323323
(timeit.default_timer() - start_time))
324-
namespaces = []
325-
self.logger.debug("Joining namespaces ...")
326-
for file_nss in namespaces:
327-
namespaces = self._join_top_namespaces(namespaces, file_nss)
328-
self.logger.debug("Joining declarations ...")
329-
for namespace in namespaces:
330-
if isinstance(namespace, pygccxml.declarations.namespace_t):
331-
declarations_joiner.join_declarations(namespace)
324+
namespaces = self.__join_namespaces_and_declarations(
325+
namespaces, namespaces
326+
)
332327
leaved_classes = self._join_class_hierarchy(namespaces)
333328
types = self.__declarated_types(namespaces)
334329
self.logger.debug("Relinking declared types ...")
@@ -354,7 +349,14 @@ def __parse_all_at_once(self, files):
354349
'#include "%s" %s' %
355350
(header, os.linesep))
356351
namespaces = self.read_string(''.join(header_content))
357-
namespaces = self._join_top_namespaces(namespaces, [])
352+
return self.__join_namespaces_and_declarations(
353+
namespaces, namespaces
354+
)
355+
356+
def __join_namespaces_and_declarations(self, main_ns_list, other_ns_list):
357+
self.logger.debug("Joining namespaces ...")
358+
namespaces = self._join_top_namespaces(main_ns_list, other_ns_list)
359+
self.logger.debug("Joining declarations ...")
358360
for namespace in namespaces:
359361
if isinstance(namespace, pygccxml.declarations.namespace_t):
360362
declarations_joiner.join_declarations(namespace)

0 commit comments

Comments
 (0)
Please sign in to comment.