speedup descriptors parsing, avoid using regexp split

master
Egor.Ushakov 8 years ago
parent 7868c0e83a
commit 6fc7ae736a
  1. 29
      src/org/jetbrains/java/decompiler/struct/consts/LinkConstant.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2000-2014 JetBrains s.r.o. * Copyright 2000-2017 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -135,31 +135,32 @@ public class LinkConstant extends PooledConstant {
} }
private void resolveDescriptor(String descr) { private void resolveDescriptor(String descr) {
int parenth = descr.indexOf(')');
if (descr.length() < 2 || parenth < 0 || descr.charAt(0) != '(') {
throw new IllegalArgumentException("Invalid descriptor: " + descr);
}
String[] arr = descr.split("[()]"); int counter = 0;
String par = arr[1]; if (parenth > 1) { // params
int index = 1;
int index = 0, counter = 0; while (index < parenth) {
int len = par.length(); char c = descr.charAt(index);
while (index < len) {
char c = par.charAt(index);
if (c == 'L') { if (c == 'L') {
index = par.indexOf(";", index); index = descr.indexOf(";", index);
} }
else if (c == '[') { else if (c == '[') {
index++; index++;
continue; continue;
} }
counter++; counter++;
index++; index++;
} }
}
paramCount = counter; paramCount = counter;
isVoid = "V".equals(arr[2]); char retChar = descr.charAt(parenth + 1);
returnCategory2 = ("D".equals(arr[2]) || "J".equals(arr[2])); isVoid = retChar == 'V';
returnCategory2 = (retChar == 'D') || (retChar == 'J');
} }
} }

Loading…
Cancel
Save