Skip to content

Commit 100e1bc

Browse files
committed
Loop optimization
1 parent a1cf279 commit 100e1bc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/main/java/com/github/packageurl/PackageURL.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -565,17 +565,18 @@ public static String uriDecode(final String source) {
565565
return source;
566566
}
567567

568-
int firstPercent = source.indexOf('%');
568+
int percent = source.indexOf('%');
569569

570-
if (firstPercent == -1) {
570+
if (percent == -1) {
571571
return source;
572572
}
573573

574574
byte[] bytes = source.getBytes(StandardCharsets.UTF_8);
575575
int length = bytes.length;
576576
ByteArrayOutputStream buffer = new ByteArrayOutputStream(length);
577+
buffer.write(bytes, 0, percent);
577578

578-
for (int i = 0; i < length; i++) {
579+
for (int i = percent; i < length; i++) {
579580
int b = bytes[i];
580581

581582
if (b == '%') {

0 commit comments

Comments
 (0)