mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8263450: Simplify LambdaForm.useCount
Reviewed-by: rriggs
This commit is contained in:
parent
75ef6f580e
commit
e33bfb3977
1 changed files with 10 additions and 12 deletions
|
@ -1598,10 +1598,13 @@ class LambdaForm {
|
||||||
* Return 0 if the name is not used.
|
* Return 0 if the name is not used.
|
||||||
*/
|
*/
|
||||||
int useCount(Name n) {
|
int useCount(Name n) {
|
||||||
if (arguments == null) return 0;
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int i = arguments.length; --i >= 0; ) {
|
if (arguments != null) {
|
||||||
if (arguments[i] == n) ++count;
|
for (Object argument : arguments) {
|
||||||
|
if (argument == n) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
@ -1649,15 +1652,10 @@ class LambdaForm {
|
||||||
|
|
||||||
/** Return the number of times n is used as an argument or return value. */
|
/** Return the number of times n is used as an argument or return value. */
|
||||||
int useCount(Name n) {
|
int useCount(Name n) {
|
||||||
int nmax = names.length;
|
int count = (result == n.index) ? 1 : 0;
|
||||||
int end = lastUseIndex(n);
|
int i = Math.max(n.index + 1, arity);
|
||||||
if (end < 0) return 0;
|
while (i < names.length) {
|
||||||
int count = 0;
|
count += names[i++].useCount(n);
|
||||||
if (end == nmax) { count++; end--; }
|
|
||||||
int beg = n.index() + 1;
|
|
||||||
if (beg < arity) beg = arity;
|
|
||||||
for (int i = beg; i <= end; i++) {
|
|
||||||
count += names[i].useCount(n);
|
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue