Skip to content

Commit e28c064

Browse files
ifradeogerritforge-ltd
authored andcommitted
Merge "MultipackIndex.PackOffset: add public static constructor"
2 parents acd1eff + a9bb14a commit e28c064

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/midx/MultiPackIndex.java

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ public interface MultiPackIndex {
4242
/**
4343
* Obtain the location of the object.
4444
* <p>
45-
* The returned object can be reused by the implementations. Callers
46-
* must create a #copy() if they want to keep a reference.
45+
* The returned object can be reused by the implementations. Callers must
46+
* create a #copy() if they want to keep a reference.
4747
*
4848
* @param objectId
4949
* objectId to read.
@@ -74,12 +74,30 @@ public interface MultiPackIndex {
7474

7575
/**
7676
* (packId, offset) coordinates of an object
77+
* <p>
78+
* Mutable object to avoid creating many instances while looking for objects
79+
* in the pack. Use #copy() to get a new instance with the data.
7780
*/
7881
class PackOffset {
7982

80-
int packId;
81-
82-
long offset;
83+
private int packId;
84+
85+
private long offset;
86+
87+
/**
88+
* Return a new PackOffset with the defined data.
89+
* <p>
90+
* This is for tests, as regular code reuses the instance
91+
*
92+
* @param packId
93+
* a pack id
94+
* @param offset
95+
* an offset
96+
* @return a new PackOffset instance with this data
97+
*/
98+
public static PackOffset create(int packId, long offset) {
99+
return new PackOffset().setValues(packId, offset);
100+
}
83101

84102
protected PackOffset setValues(int packId, long offset) {
85103
this.packId = packId;

0 commit comments

Comments
 (0)