Skip to content

Commit

Permalink
LDEV-5156 allow configuring the default capacity for local and argume…
Browse files Browse the repository at this point in the history
  • Loading branch information
zspitzer committed Nov 21, 2024
1 parent 35915ab commit 8492e25
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Map;
import java.util.Set;

import lucee.commons.io.SystemUtil;
import lucee.commons.lang.CFTypes;
import lucee.runtime.PageContext;
import lucee.runtime.config.NullSupportHelper;
Expand Down Expand Up @@ -63,14 +64,19 @@ public final class ArgumentImpl extends ScopeSupport implements Argument, ArrayP

private boolean bind;
private Set functionArgumentNames;
private static int argumentInitialCapacity;

static {
argumentInitialCapacity = Caster.toIntValue(SystemUtil.getSystemPropOrEnvVar("lucee.scope.arguments.capacity", "4"), 4);
}
// private boolean supportFunctionArguments;

/**
* constructor of the class
*/
public ArgumentImpl() {
// super("arguments", SCOPE_ARGUMENTS, StructImpl.TYPE_LINKED, 4);
super("arguments", SCOPE_ARGUMENTS, StructImpl.TYPE_LINKED_NOT_SYNC, 4);
super("arguments", SCOPE_ARGUMENTS, StructImpl.TYPE_LINKED_NOT_SYNC, argumentInitialCapacity);
}

@Override
Expand Down
9 changes: 8 additions & 1 deletion core/src/main/java/lucee/runtime/type/scope/LocalImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,24 @@
**/
package lucee.runtime.type.scope;

import lucee.commons.io.SystemUtil;
import lucee.runtime.PageContext;
import lucee.runtime.op.Caster;
import lucee.runtime.type.Struct;

public final class LocalImpl extends ScopeSupport implements Scope, Local {

private static final long serialVersionUID = -7155406303949924403L;
private boolean bind;
private static int localInitialCapacity;

static {
localInitialCapacity = Caster.toIntValue(SystemUtil.getSystemPropOrEnvVar("lucee.scope.local.capacity", "4"), 4);
}

public LocalImpl() {
// super("local", Scope.SCOPE_LOCAL, Struct.TYPE_SYNC, 4);
super("local", Scope.SCOPE_LOCAL, Struct.TYPE_REGULAR, 4);
super("local", Scope.SCOPE_LOCAL, Struct.TYPE_REGULAR, localInitialCapacity);
}

@Override
Expand Down
10 changes: 10 additions & 0 deletions core/src/main/java/resource/setting/sysprop-envvar.json
Original file line number Diff line number Diff line change
Expand Up @@ -368,5 +368,15 @@
"sysprop": "lucee.template.charset",
"envvar": "LUCEE_TEMPLATE_CHARSET",
"desc": ""
},
{
"sysprop": "lucee.scope.local.capacity",
"envvar": "LUCEE_SCOPE_LOCAL_CAPACITY",
"desc": "Sets the initial capacity (size) for the local scope hashmap"
},
{
"sysprop": "lucee.scopes.arguments.capacity",
"envvar": "LUCEE_SCOPE_ARGUMENTS_CAPACITY",
"desc": "Sets the initial capacity (size) for the arguments scope hashmap"
}
]

0 comments on commit 8492e25

Please sign in to comment.