You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ta...@apache.org on 2020/08/11 08:41:05 UTC

[myfaces] branch master updated: [perf] reduce get operations

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

tandraschko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces.git


The following commit(s) were added to refs/heads/master by this push:
     new ec15f54  [perf] reduce get operations
ec15f54 is described below

commit ec15f540a18cfc5ce4e15740069f85000c59a129
Author: Thomas Andraschko <ta...@apache.org>
AuthorDate: Tue Aug 11 10:40:56 2020 +0200

    [perf] reduce get operations
---
 .../view/facelets/impl/SectionUniqueIdCounter.java | 46 +++++++++-------------
 1 file changed, 19 insertions(+), 27 deletions(-)

diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/impl/SectionUniqueIdCounter.java b/impl/src/main/java/org/apache/myfaces/view/facelets/impl/SectionUniqueIdCounter.java
index b75951b..19daf6d 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/impl/SectionUniqueIdCounter.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/impl/SectionUniqueIdCounter.java
@@ -111,13 +111,13 @@ public class SectionUniqueIdCounter
         
         if (!_counterStack.isEmpty())
         {
-            String lastPrefix = _counterStack.get(_counterStack.size()-1).getPrefix();
+            String lastPrefix = _counterStack.get(_counterStack.size() - 1).getPrefix();
             if (lastPrefix != null)
             {
                 _builder.append(lastPrefix);
                 _builder.append('_');
             }
-            appendToBuilder(_counterStack.get(_counterStack.size()-1).getCounter(),
+            appendToBuilder(_counterStack.get(_counterStack.size() - 1).getCounter(),
                 _radix, _builder, _bufferConversion);
         }
         
@@ -133,13 +133,13 @@ public class SectionUniqueIdCounter
         
         if (!_counterStack.isEmpty())
         {
-            String lastPrefix = _counterStack.get(_counterStack.size()-1).getPrefix();
+            String lastPrefix = _counterStack.get(_counterStack.size() - 1).getPrefix();
             if (lastPrefix != null)
             {
                 _builder.append(lastPrefix);
                 _builder.append('_');
             }
-            appendToBuilder(_counterStack.get(_counterStack.size()-1).getCounter()-1,
+            appendToBuilder(_counterStack.get(_counterStack.size() - 1).getCounter() - 1,
                 _radix, _builder, _bufferConversion);
         }
 
@@ -155,23 +155,19 @@ public class SectionUniqueIdCounter
 
     public String generateUniqueId()
     {
+        Section activeSection = _counterStack.get(_activeSection);
+
         if (_activeSection == 0 && _uniqueIdsCache != null)
         {
-            long i = _counterStack.get(_activeSection).getCounter();
-            if (((int)i) < (long)_uniqueIdsCache.length)
-            {
-                _counterStack.get(_activeSection).incrementUniqueId();
-                return _uniqueIdsCache[((int)i)-1];
-            }
-            else
+            long i = activeSection.getCounter();
+            if (((int) i) < ((long) _uniqueIdsCache.length))
             {
-                return _counterStack.get(_activeSection).generateUniqueId(_prefix);
+                activeSection.incrementUniqueId();
+                return _uniqueIdsCache[((int) i) - 1];
             }
         }
-        else
-        {
-            return _counterStack.get(_activeSection).generateUniqueId(_prefix);
-        }
+
+        return activeSection.generateUniqueId(_prefix);
     }
     
     public void generateUniqueId(StringBuilder builderToAdd)
@@ -191,12 +187,10 @@ public class SectionUniqueIdCounter
             _counterStack.get(_activeSection).generateUniqueId(_prefix);
             return;
         }
-        else
-        {
-            _counterStack.remove(_activeSection);
-            _activeSection--;
-            _counterStack.get(_activeSection).generateUniqueId(_prefix);
-        }
+
+        _counterStack.remove(_activeSection);
+        _activeSection--;
+        _counterStack.get(_activeSection).generateUniqueId(_prefix);
     }
     
     public void endUniqueIdSection(String base)
@@ -205,11 +199,9 @@ public class SectionUniqueIdCounter
         {
             return;
         }
-        else
-        {
-            _counterStack.remove(_activeSection);
-            _activeSection--;
-        }
+
+        _counterStack.remove(_activeSection);
+        _activeSection--;
     }
     
     private static class Section