From 00ce31ad308ff4c7ef874d2fa64374f47980c85c Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 15 Nov 2010 16:53:12 +0100 Subject: Objects: Constructor now manually checks and sets the input arguments to the local cache - previously a procedural approach was used, which was less code, but slower too. Especially in case of CommitObjects unrolling the loop manually makes a difference. Submodule: Implemented query methods and did a bit of testing. More is to come, but the test works for now. As special addition, the submodule implementation uses the section name as submodule ID even though it seems to be just the path. This allows to make renames easier --- lib/git/objects/base.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'lib/git/objects/base.py') diff --git a/lib/git/objects/base.py b/lib/git/objects/base.py index 41862ac2..82c2589c 100644 --- a/lib/git/objects/base.py +++ b/lib/git/objects/base.py @@ -62,17 +62,6 @@ class Object(LazyMixin): inst.size = oinfo.size return inst - def _set_self_from_args_(self, args_dict): - """Initialize attributes on self from the given dict that was retrieved - from locals() in the calling method. - - Will only set an attribute on self if the corresponding value in args_dict - is not None""" - for attr, val in args_dict.items(): - if attr != "self" and val is not None: - setattr( self, attr, val ) - # END set all non-None attributes - def _set_cache_(self, attr): """Retrieve object information""" if attr == "size": @@ -140,7 +129,10 @@ class IndexObject(Object): Path may not be set of the index object has been created directly as it cannot be retrieved without knowing the parent tree.""" super(IndexObject, self).__init__(repo, binsha) - self._set_self_from_args_(locals()) + if mode is not None: + self.mode = mode + if path is not None: + self.path = path def __hash__(self): """:return: -- cgit v1.2.1