Skip to content

Commit dc57b88

Browse files
committed
If there is a ':' in the URI at index schemeLen, then we do not need to
search for it again - No need to ask the URI for its length over and over - Normalize Javadoc
1 parent 856b5ba commit dc57b88

File tree

1 file changed

+8
-5
lines changed
  • commons-vfs2/src/main/java/org/apache/commons/vfs2/provider

1 file changed

+8
-5
lines changed

commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/UriParser.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -433,10 +433,12 @@ public static String extractScheme(final String[] schemes, final String uri, fin
433433
buffer.setLength(0);
434434
buffer.append(uri);
435435
}
436+
final int uriLength = uri.length();
436437
for (final String scheme : schemes) {
437-
if (uri.startsWith(scheme) && uri.length() > scheme.length() && uri.charAt(scheme.length()) == ':') {
438+
final int schemeLen = scheme.length();
439+
if (uri.startsWith(scheme) && uriLength > schemeLen && uri.charAt(schemeLen) == ':') {
438440
if (buffer != null) {
439-
buffer.delete(0, uri.indexOf(':') + 1);
441+
buffer.delete(0, schemeLen + 1);
440442
}
441443
return scheme;
442444
}
@@ -445,7 +447,7 @@ public static String extractScheme(final String[] schemes, final String uri, fin
445447
}
446448

447449
/**
448-
* Normalises the separators in a name.
450+
* Normalizes the separators in a name.
449451
*
450452
* @param name The StringBuilder containing the name
451453
* @return true if the StringBuilder was modified.
@@ -477,14 +479,15 @@ public static boolean fixSeparators(final StringBuilder name) {
477479
}
478480

479481
/**
480-
* Normalises a path. Does the following:
482+
* Normalizes a path. Does the following:
481483
* <ul>
482484
* <li>Removes empty path elements.
483485
* <li>Handles '.' and '..' elements.
484486
* <li>Removes trailing separator.
485487
* </ul>
486-
*
488+
* <p>
487489
* Its assumed that the separators are already fixed.
490+
* </p>
488491
*
489492
* @param path The path to normalize.
490493
* @return The FileType.

0 commit comments

Comments
 (0)