Skip to content

Commit

Permalink
specialise variable read with closure scope
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeloffner committed Dec 15, 2023
1 parent 9e5ffb9 commit e50d359
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 17 deletions.
54 changes: 39 additions & 15 deletions core/src/main/java/lucee/runtime/type/scope/ClosureScope.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,25 @@ public void clear() {

@Override
public Object get(Key key) throws PageException {
return get((PageContext) null, key);
Object value = local.get(key, CollectionUtil.NULL);
if (value != CollectionUtil.NULL) return value;
value = arg.get(key, CollectionUtil.NULL);
if (value != CollectionUtil.NULL) {
if (debug) UndefinedImpl.debugCascadedAccess(ThreadLocalPageContext.get(), arg.getTypeAsString(), key);
return value;
}

value = var.get(key);
if (debug) UndefinedImpl.debugCascadedAccess(ThreadLocalPageContext.get(), var.getTypeAsString(), key);
return value;
}

@Override
public Object get(PageContext pc, Key key) throws PageException {
Object _null = CollectionUtil.NULL;
Object value = local.get(pc, key, _null);
if (value != _null) return value;
value = arg.get(pc, key, _null);
if (value != _null) {
Object value = local.get(pc, key, CollectionUtil.NULL);
if (value != CollectionUtil.NULL) return value;
value = arg.get(pc, key, CollectionUtil.NULL);
if (value != CollectionUtil.NULL) {
if (debug) UndefinedImpl.debugCascadedAccess(ThreadLocalPageContext.get(pc), arg.getTypeAsString(), key);
return value;
}
Expand All @@ -181,27 +190,42 @@ public Object get(PageContext pc, Key key) throws PageException {

@Override
public Object get(Key key, Object defaultValue) {
return get(null, key, defaultValue);
// local
Object value = local.get(key, CollectionUtil.NULL);
if (value != CollectionUtil.NULL) return value;

// arg
value = arg.get(key, CollectionUtil.NULL);
if (value != CollectionUtil.NULL) {
if (debug) UndefinedImpl.debugCascadedAccess(ThreadLocalPageContext.get(), arg.getTypeAsString(), key);
return value;
}

// var
value = var.get(key, CollectionUtil.NULL);
if (value != CollectionUtil.NULL) {
if (debug) UndefinedImpl.debugCascadedAccess(ThreadLocalPageContext.get(), var.getTypeAsString(), key);
return value;
}
return defaultValue;
}

@Override
public Object get(PageContext pc, Key key, Object defaultValue) {
Object _null = CollectionUtil.NULL;

// local
Object value = local.get(pc, key, _null);
if (value != _null) return value;
Object value = local.get(pc, key, CollectionUtil.NULL);
if (value != CollectionUtil.NULL) return value;

// arg
value = arg.get(pc, key, _null);
if (value != _null) {
value = arg.get(pc, key, CollectionUtil.NULL);
if (value != CollectionUtil.NULL) {
if (debug) UndefinedImpl.debugCascadedAccess(ThreadLocalPageContext.get(pc), arg.getTypeAsString(), key);
return value;
}

// var
value = var.get(pc, key, _null);
if (value != _null) {
value = var.get(pc, key, CollectionUtil.NULL);
if (value != CollectionUtil.NULL) {
if (debug) UndefinedImpl.debugCascadedAccess(ThreadLocalPageContext.get(pc), var.getTypeAsString(), key);
return value;
}
Expand Down
2 changes: 1 addition & 1 deletion loader/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<project default="core" basedir="." name="Lucee"
xmlns:resolver="antlib:org.apache.maven.resolver.ant">

<property name="version" value="6.1.0.12-ALPHA"/>
<property name="version" value="6.1.0.13-ALPHA"/>

<taskdef uri="antlib:org.apache.maven.resolver.ant" resource="org/apache/maven/resolver/ant/antlib.xml">
<classpath>
Expand Down
2 changes: 1 addition & 1 deletion loader/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>org.lucee</groupId>
<artifactId>lucee</artifactId>
<version>6.1.0.12-ALPHA</version>
<version>6.1.0.13-ALPHA</version>
<packaging>jar</packaging>

<name>Lucee Loader Build</name>
Expand Down

0 comments on commit e50d359

Please sign in to comment.