private final File packFile;
+ private volatile String packName;
+
final int hash;
private RandomAccessFile fd;
/** @return name extracted from {@code pack-*.pack} pattern. */
public String getPackName() {
- String name = getPackFile().getName();
- if (name.startsWith("pack-"))
- name = name.substring("pack-".length());
- if (name.endsWith(".pack"))
- name = name.substring(0, name.length() - ".pack".length());
+ String name = packName;
+ if (name == null) {
+ name = getPackFile().getName();
+ if (name.startsWith("pack-"))
+ name = name.substring("pack-".length());
+ if (name.endsWith(".pack"))
+ name = name.substring(0, name.length() - ".pack".length());
+ packName = name;
+ }
return name;
}