diff options
author | Benoit Lamarche <benoitlamarche@google.com> | 2015-02-18 15:53:32 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-02-18 15:53:33 +0000 |
commit | 9c89ff579e5fb6d6a62d3743d0696a9c012935c4 (patch) | |
tree | 6e12bff6546dd57ddadedbbbe70ef795c36701e2 /sched | |
parent | 877af2e6a25b683f3de1135eed80641fd41b6558 (diff) | |
parent | 7862998ee70c46eec7b13efeed2c23b589b9c6ea (diff) | |
download | toolchain_jack-9c89ff579e5fb6d6a62d3743d0696a9c012935c4.tar.gz toolchain_jack-9c89ff579e5fb6d6a62d3743d0696a9c012935c4.tar.bz2 toolchain_jack-9c89ff579e5fb6d6a62d3743d0696a9c012935c4.zip |
Merge "Optimize VPath append and prepend" into ub-jack
Diffstat (limited to 'sched')
-rw-r--r-- | sched/src/com/android/sched/vfs/VPath.java | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/sched/src/com/android/sched/vfs/VPath.java b/sched/src/com/android/sched/vfs/VPath.java index 0eeae394..e18c32b7 100644 --- a/sched/src/com/android/sched/vfs/VPath.java +++ b/sched/src/com/android/sched/vfs/VPath.java @@ -50,9 +50,11 @@ public final class VPath implements Cloneable { */ public VPath(@Nonnull CharSequence path, char separator) { pathFragments = new ArrayList<VPathFragment>(1); - VPathFragment pe = new VPathFragment(path, separator); - assert pe.isValidPath(); - pathFragments.add(pe); + if (path.length() > 0) { + VPathFragment pe = new VPathFragment(path, separator); + assert pe.isValidPath(); + pathFragments.add(pe); + } } private VPath(ArrayList<VPathFragment> pathFragments) { @@ -66,7 +68,8 @@ public final class VPath implements Cloneable { * @return the current path */ public VPath prependPath(@Nonnull VPath path) { - if (!this.equals(VPath.ROOT)) { + assert !path.isRoot(); + if (!this.isRoot()) { pathFragments.add(0, new VPathFragment(String.valueOf(INTERNAL_SEPARATOR), INTERNAL_SEPARATOR)); } @@ -82,7 +85,8 @@ public final class VPath implements Cloneable { * @return the current path */ public VPath appendPath(@Nonnull VPath path) { - if (!this.equals(VPath.ROOT)) { + assert !path.isRoot(); + if (!this.isRoot()) { pathFragments.add(new VPathFragment(String.valueOf(INTERNAL_SEPARATOR), INTERNAL_SEPARATOR)); } pathFragments.addAll(path.getPathFragments()); @@ -168,6 +172,10 @@ public final class VPath implements Cloneable { return getPathAsString(INTERNAL_SEPARATOR); } + public boolean isRoot() { + return pathFragments.isEmpty(); + } + /** * A portion of path that should be immutable. */ |