Skip to content

Commit

Permalink
optimization[2/2]: only parse essential commit info upon initialization
Browse files Browse the repository at this point in the history
Minimal information needed to traverse the graph:
+ commit-id (sha1) to uniquely identify the commit.
+ tree-id (sha1) to access the tree and object-ids associated with the commit.
+ list of parent-id (sha1)s. + raw committer date, ignoring the timezone.

For better efficiency, we extract only what we need, and cache the rest
in an NSData object for later extraction.
Lazily fetched properties are:
author + authored + committer + committed + message

Currently lazy-fetching is as simple as possible, a call to any of the above
methods will cause all of the cached data to be parsed, filling in the rest of
the data.

Signed-off-by: Geoff Garside <geoff@geoffgarside.co.uk>
  • Loading branch information
chapados authored and geoffgarside committed Jun 17, 2009
1 parent 475ae99 commit 9940ed5
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 315 deletions.
5 changes: 4 additions & 1 deletion Source/Types/GITCommit.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,23 @@ extern NSString * const kGITObjectCommitName;

GITDateTime * authored;
GITDateTime * committed;
unsigned long sortDate;

NSString * message;
NSData *cachedRawData;
}

@property(readonly,copy) NSString * treeSha1;
@property(readonly,copy) NSString * parentSha1;
@property(readwrite,copy) NSArray * parentShas;
@property(readwrite,retain) NSArray * parentShas;
@property(readonly,copy) GITTree * tree;
@property(readonly,copy) GITCommit * parent;
@property(readonly,copy) NSArray *parents;
@property(readonly,copy) GITActor * author;
@property(readonly,copy) GITActor * committer;
@property(readonly,copy) GITDateTime * authored;
@property(readonly,copy) GITDateTime * committed;
@property(readonly) unsigned long sortDate;
@property(readonly,copy) NSString * message;

- (BOOL)isFirstCommit;
Expand Down
Loading

0 comments on commit 9940ed5

Please sign in to comment.