You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2022/02/19 17:55:18 UTC

[tomcat] branch 8.5.x updated: Minor optimisation.

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 9e16090  Minor optimisation.
9e16090 is described below

commit 9e16090b3375d6ebba65b2d933304dcb2a00591e
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Sat Feb 19 17:39:43 2022 +0000

    Minor optimisation.
    
    Previous two fixes were applied for the same issue:
    - https://bz.apache.org/bugzilla/show_bug.cgi?id=41797
    - https://bz.apache.org/bugzilla/show_bug.cgi?id=44428
    
    The call to getMethod() is not necessary. Either this is the original
    object - in which case the fields will be null and m will be populated
    or the object has been previously deserialized and the fields can be
    used directly without any need to create the method.
---
 java/org/apache/el/lang/FunctionMapperImpl.java | 21 +++++++++------------
 webapps/docs/changelog.xml                      |  4 ++++
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/java/org/apache/el/lang/FunctionMapperImpl.java b/java/org/apache/el/lang/FunctionMapperImpl.java
index dc7ff0a..6e9deab 100644
--- a/java/org/apache/el/lang/FunctionMapperImpl.java
+++ b/java/org/apache/el/lang/FunctionMapperImpl.java
@@ -122,18 +122,15 @@ public class FunctionMapperImpl extends FunctionMapper implements
         public void writeExternal(ObjectOutput out) throws IOException {
             out.writeUTF((this.prefix != null) ? this.prefix : "");
             out.writeUTF(this.localName);
-            // make sure m isn't null
-            getMethod();
-            out.writeUTF((this.owner != null) ?
-                     this.owner :
-                     this.m.getDeclaringClass().getName());
-            out.writeUTF((this.name != null) ?
-                     this.name :
-                     this.m.getName());
-            out.writeObject((this.types != null) ?
-                     this.types :
-                     ReflectionUtil.toTypeNameArray(this.m.getParameterTypes()));
-
+            if (this.owner != null && this.name != null && this.types != null) {
+                out.writeUTF(this.owner);
+                out.writeUTF(this.name);
+                out.writeObject(this.types);
+            } else {
+                out.writeUTF(this.m.getDeclaringClass().getName());
+                out.writeUTF(this.m.getName());
+                out.writeObject(this.m.getParameterTypes());
+            }
         }
 
         /*
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index a2933ee..2475d75 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -210,6 +210,10 @@
         <pr>474</pr>: Prevent a tag file from corrupting the ELContext of the
         calling page. Pull request provided by Dmitri Blinov. (markt)
       </fix>
+      <fix>
+        Minor optimisation of serialization for <code>FunctionMapperImpl</code>
+        in response to pull request <pr>476</pr>. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Web applications">

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org