DFS: Override exactRef() with optimal version

This avoids scanning a directory to find all names and
then weeding down to the requested name.

Change-Id: I36ce31febad6e881182bc3a278c7ed35cc04cbda
This commit is contained in:
Shawn Pearce 2015-07-16 14:31:50 -07:00
parent 39dc898dca
commit d0e47a99aa
1 changed files with 7 additions and 0 deletions

View File

@ -90,6 +90,13 @@ boolean exists() throws IOException {
return 0 < read().size();
}
@Override
public Ref exactRef(String name) throws IOException {
RefCache curr = read();
Ref ref = curr.ids.get(name);
return ref != null ? resolve(ref, 0, curr.ids) : null;
}
@Override
public Ref getRef(String needle) throws IOException {
RefCache curr = read();