You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2020/09/18 00:24:19 UTC

[groovy] branch master updated: Trivial refactoring: extract common variable

This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new 5fdf048  Trivial refactoring: extract common variable
5fdf048 is described below

commit 5fdf048d8d099e58d87a7cb66e080217d48c1031
Author: Daniel Sun <su...@apache.org>
AuthorDate: Fri Sep 18 08:24:04 2020 +0800

    Trivial refactoring: extract common variable
---
 src/main/java/groovy/lang/MetaClassImpl.java | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/main/java/groovy/lang/MetaClassImpl.java b/src/main/java/groovy/lang/MetaClassImpl.java
index 3aa3a3d..676693f 100644
--- a/src/main/java/groovy/lang/MetaClassImpl.java
+++ b/src/main/java/groovy/lang/MetaClassImpl.java
@@ -2551,11 +2551,12 @@ public class MetaClassImpl implements MetaClass, MutableMetaClass {
             for (MetaMethodIndex.Entry e = header.head; e != null; e = e.nextClassEntry) {
                 String methodName = e.name;
                 // name too short?
-                if (methodName.length() < 3 ||
-                        (!methodName.startsWith("is") && methodName.length() < 4)) continue;
+                final int methodNameLength = methodName.length();
+                if (methodNameLength < 3 ||
+                        (methodNameLength < 4 && !methodName.startsWith("is"))) continue;
                 // possible getter/setter?
-                boolean isGetter = methodName.startsWith("get") || methodName.startsWith("is");
                 boolean isBooleanGetter = methodName.startsWith("is");
+                boolean isGetter = methodName.startsWith("get") || isBooleanGetter;
                 boolean isSetter = methodName.startsWith("set");
                 if (!isGetter && !isSetter) continue;