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

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

commit 651334e87a2b29d13ba5ed9147a91febe7a12e67
Author: Eric Milles <[email protected]>
AuthorDate: Thu Jan 15 15:34:48 2026 -0600

    GROOVY-11841: reduce nesting and mutation
---
 src/main/java/groovy/lang/MetaClassImpl.java | 40 +++++++++++++++++-----------
 1 file changed, 25 insertions(+), 15 deletions(-)

diff --git a/src/main/java/groovy/lang/MetaClassImpl.java 
b/src/main/java/groovy/lang/MetaClassImpl.java
index 912dfa427d..76f7e8c5d1 100644
--- a/src/main/java/groovy/lang/MetaClassImpl.java
+++ b/src/main/java/groovy/lang/MetaClassImpl.java
@@ -291,25 +291,35 @@ public class MetaClassImpl implements MetaClass, 
MutableMetaClass {
      */
     @Override
     public MetaProperty getMetaProperty(final String name) {
-        MetaProperty metaProperty = null;
+        MetaProperty metaProperty;
 
-        Map<String, MetaProperty> propertyMap = subMap(classPropertyIndex, 
theCachedClass);
-        metaProperty = propertyMap.get(name);
-        if (metaProperty == null) {
-            metaProperty = staticPropertyIndex.get(name);
-            if (metaProperty == null) {
-                propertyMap = subMap(classPropertyIndexForSuper, 
theCachedClass);
-                metaProperty = propertyMap.get(name);
-                if (metaProperty == null) {
-                    MetaBeanProperty property = 
findPropertyInClassHierarchy(name, theCachedClass);
-                    if (property != null) {
-                        onSuperPropertyFoundInHierarchy(property);
-                        metaProperty = property;
-                    }
-                }
+        var propertyMap = classPropertyIndex.get(theCachedClass);
+        if (propertyMap != null) {
+            metaProperty = propertyMap.get(name);
+            if (metaProperty != null) {
+                return metaProperty;
             }
         }
 
+        metaProperty = staticPropertyIndex.get(name);
+        if (metaProperty != null) {
+            return metaProperty;
+        }
+
+        propertyMap = classPropertyIndexForSuper.get(theCachedClass);
+        if (propertyMap != null) {
+            metaProperty = propertyMap.get(name);
+            if (metaProperty != null) {
+                return metaProperty;
+            }
+        }
+
+        var metaBeanProperty = findPropertyInClassHierarchy(name, 
theCachedClass);
+        if (metaBeanProperty != null) {
+            metaProperty = metaBeanProperty;
+            onSuperPropertyFoundInHierarchy(metaBeanProperty);
+        }
+
         return metaProperty;
     }
 

Reply via email to