Skip to content
Permalink
Browse files
8263450: Simplify LambdaForm.useCount
Reviewed-by: rriggs
  • Loading branch information
cl4es committed Mar 16, 2021
1 parent 75ef6f5 commit e33bfb3977153e9c74261d1836b2cb153c47c192
Showing with 10 additions and 12 deletions.
  1. +10 −12 src/java.base/share/classes/java/lang/invoke/LambdaForm.java
@@ -1598,10 +1598,13 @@ int lastUseIndex(Name n) {
* Return 0 if the name is not used.
*/
int useCount(Name n) {
if (arguments == null) return 0;
int count = 0;
for (int i = arguments.length; --i >= 0; ) {
if (arguments[i] == n) ++count;
if (arguments != null) {
for (Object argument : arguments) {
if (argument == n) {
count++;
}
}
}
return count;
}
@@ -1649,15 +1652,10 @@ int lastUseIndex(Name n) {

/** Return the number of times n is used as an argument or return value. */
int useCount(Name n) {
int nmax = names.length;
int end = lastUseIndex(n);
if (end < 0) return 0;
int count = 0;
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);
int count = (result == n.index) ? 1 : 0;
int i = Math.max(n.index + 1, arity);
while (i < names.length) {
count += names[i++].useCount(n);
}
return count;
}

1 comment on commit e33bfb3

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on e33bfb3 Mar 16, 2021

Please sign in to comment.