This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push:
new f71875c Lazy init ELContext#listeners to avoid unnecessary ArrayList
and ArrayList$Itr instances
f71875c is described below
commit f71875cd77e79b35872a854c7d6c509e7fdfda72
Author: Thomas Andraschko <[email protected]>
AuthorDate: Wed Sep 9 11:15:01 2020 +0200
Lazy init ELContext#listeners to avoid unnecessary ArrayList and
ArrayList$Itr instances
---
java/javax/el/ELContext.java | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/java/javax/el/ELContext.java b/java/javax/el/ELContext.java
index cd68a78..ca184ca 100644
--- a/java/javax/el/ELContext.java
+++ b/java/javax/el/ELContext.java
@@ -36,7 +36,7 @@ public abstract class ELContext {
private ImportHandler importHandler = null;
- private List<EvaluationListener> listeners = new ArrayList<>();
+ private List<EvaluationListener> listeners;
private Deque<Map<String,Object>> lambdaArguments = new LinkedList<>();
@@ -143,6 +143,10 @@ public abstract class ELContext {
* @since EL 3.0
*/
public void addEvaluationListener(EvaluationListener listener) {
+ if (listeners == null) {
+ listeners = new ArrayList<>();
+ }
+
listeners.add(listener);
}
@@ -154,7 +158,7 @@ public abstract class ELContext {
* @since EL 3.0
*/
public List<EvaluationListener> getEvaluationListeners() {
- return listeners;
+ return listeners == null ? Collections.emptyList() : listeners;
}
/**
@@ -165,6 +169,10 @@ public abstract class ELContext {
* @since EL 3.0
*/
public void notifyBeforeEvaluation(String expression) {
+ if (listeners == null) {
+ return;
+ }
+
for (EvaluationListener listener : listeners) {
try {
listener.beforeEvaluation(this, expression);
@@ -183,6 +191,10 @@ public abstract class ELContext {
* @since EL 3.0
*/
public void notifyAfterEvaluation(String expression) {
+ if (listeners == null) {
+ return;
+ }
+
for (EvaluationListener listener : listeners) {
try {
listener.afterEvaluation(this, expression);
@@ -202,6 +214,10 @@ public abstract class ELContext {
* @since EL 3.0
*/
public void notifyPropertyResolved(Object base, Object property) {
+ if (listeners == null) {
+ return;
+ }
+
for (EvaluationListener listener : listeners) {
try {
listener.propertyResolved(this, base, property);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]