This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new a258c11c7e Fix BZ 68546 - minor optimization
a258c11c7e is described below

commit a258c11c7e4bfb9236a6278eec96716e941ed349
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Jun 3 15:16:24 2024 +0100

    Fix BZ 68546 - minor optimization
    
    Based on a patch by Dan Armstrong
---
 java/org/apache/jasper/compiler/Generator.java | 5 +++--
 webapps/docs/changelog.xml                     | 9 +++++++++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/jasper/compiler/Generator.java 
b/java/org/apache/jasper/compiler/Generator.java
index 84f1c3e9b9..efbf17588a 100644
--- a/java/org/apache/jasper/compiler/Generator.java
+++ b/java/org/apache/jasper/compiler/Generator.java
@@ -621,7 +621,8 @@ class Generator {
         // Packages is never empty because o.a.j.Constants.STANDARD_IMPORTS
         // contains 3 packages and is always added to the imports.
         out.printin("_jspx_imports_packages = new java.util.LinkedHashSet<>(");
-        out.print(Integer.toString(packages.size()));
+        // Allow for the default load factor of 0.75
+        out.print(Integer.toString((int) Math.ceil(packages.size() / 0.75)));
         out.print(");");
         out.println();
         for (String packageName : packages) {
@@ -635,7 +636,7 @@ class Generator {
             out.println();
         } else {
             out.printin("_jspx_imports_classes = new 
java.util.LinkedHashSet<>(");
-            out.print(Integer.toString(classes.size()));
+            out.print(Integer.toString((int) Math.ceil(classes.size() / 
0.75)));
             out.print(");");
             out.println();
             for (String className : classes) {
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index b8293139f2..cd704f988c 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -136,6 +136,15 @@
       </fix>
     </changelog>
   </subsection>
+  <subsection name="Jasper">
+    <changelog>
+      <fix>
+        <bug>68546</bug>: Small additional optimisation for initial loading of
+        Servlet code generated for JSPs. Based on a suggestion by Dan 
Armstrong.
+        (markt)
+      </fix>
+    </changelog>
+  </subsection>
   <subsection name="Other">
     <changelog>
       <update>


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

Reply via email to