Allow mutable object ids, improving commit parsing performance
commita5af35d0ed1dd25ac981fb0e4d636934299673a9
authorShawn O. Pearce <spearce@spearce.org>
Fri, 21 Mar 2008 02:37:55 +0000 (20 22:37 -0400)
committerShawn O. Pearce <spearce@spearce.org>
Mon, 7 Apr 2008 05:05:54 +0000 (7 01:05 -0400)
tree62055e9f585c18b3a87e3243f94e9bef9d5e6340
parent2dcfdd6840866fb7bc2c986a883de33683a29750
Allow mutable object ids, improving commit parsing performance

One of the larger expenses during RevWalk is RevCommit's hidden
parseCanonical method, which spends most of its time parsing the
tree and parent references from hex SHA-1 strings into ObjectIds,
and then mapping them through RevWalk's map.  By creating a new
mutable ObjectId variant we can recycle this mutable value and
avoid direct allocation costs.  Typically we will parse each of
the SHA-1 values, not find it in the map, and then need to create
a new RevObject instance to reference the object.  The mutable
instance as our lookup key saves one object creation.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
15 files changed:
org.spearce.jgit/src/org/spearce/jgit/lib/AnyObjectId.java [copied from org.spearce.jgit/src/org/spearce/jgit/lib/ObjectId.java with 55% similarity]
org.spearce.jgit/src/org/spearce/jgit/lib/MutableObjectId.java [new file with mode: 0644]
org.spearce.jgit/src/org/spearce/jgit/lib/ObjectId.java
org.spearce.jgit/src/org/spearce/jgit/lib/ObjectIdSubclassMap.java
org.spearce.jgit/src/org/spearce/jgit/lib/PackFile.java
org.spearce.jgit/src/org/spearce/jgit/lib/PackIndex.java
org.spearce.jgit/src/org/spearce/jgit/lib/PackIndexV1.java
org.spearce.jgit/src/org/spearce/jgit/lib/PackIndexV2.java
org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
org.spearce.jgit/src/org/spearce/jgit/revwalk/RevBlob.java
org.spearce.jgit/src/org/spearce/jgit/revwalk/RevCommit.java
org.spearce.jgit/src/org/spearce/jgit/revwalk/RevObject.java
org.spearce.jgit/src/org/spearce/jgit/revwalk/RevTag.java
org.spearce.jgit/src/org/spearce/jgit/revwalk/RevTree.java
org.spearce.jgit/src/org/spearce/jgit/revwalk/RevWalk.java