This is an automated email from the ASF dual-hosted git repository.
emilles 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 40d5d89168 GROOVY-11841: reduce nesting and mutation
40d5d89168 is described below
commit 40d5d8916812a6dbb7736e39b08c2f4204b421d3
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 | 42 +++++++++++++++++-----------
1 file changed, 26 insertions(+), 16 deletions(-)
diff --git a/src/main/java/groovy/lang/MetaClassImpl.java
b/src/main/java/groovy/lang/MetaClassImpl.java
index 36fe87d98b..b2e437145a 100644
--- a/src/main/java/groovy/lang/MetaClassImpl.java
+++ b/src/main/java/groovy/lang/MetaClassImpl.java
@@ -288,25 +288,35 @@ public class MetaClassImpl implements MetaClass,
MutableMetaClass {
*/
@Override
public MetaProperty getMetaProperty(final String name) {
- MetaProperty metaProperty = null;
-
- 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;
- }
- }
+ MetaProperty metaProperty;
+
+ 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;
}