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

dlmarion pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo-access.git


The following commit(s) were added to refs/heads/main by this push:
     new be1b160  Remove duplicate method calls in AccessEvaluator methods (#99)
be1b160 is described below

commit be1b16019d80c0d5f243677fc2eaf0342b4cf5f6
Author: Dave Marion <[email protected]>
AuthorDate: Thu Jan 15 18:10:09 2026 -0500

    Remove duplicate method calls in AccessEvaluator methods (#99)
---
 .../apache/accumulo/access/AuthorizationValidator.java |  3 ++-
 .../accumulo/access/impl/AccessEvaluatorImpl.java      | 18 ++++++++++--------
 .../accumulo/access/impl/AccessExpressionImpl.java     |  4 ++--
 3 files changed, 14 insertions(+), 11 deletions(-)

diff --git 
a/core/src/main/java/org/apache/accumulo/access/AuthorizationValidator.java 
b/core/src/main/java/org/apache/accumulo/access/AuthorizationValidator.java
index 7baa907..31dfef2 100644
--- a/core/src/main/java/org/apache/accumulo/access/AuthorizationValidator.java
+++ b/core/src/main/java/org/apache/accumulo/access/AuthorizationValidator.java
@@ -104,7 +104,8 @@ public interface AuthorizationValidator
     }
 
     // Unsure what characters are present, so must validate them all.
-    for (int i = 0; i < auth.length(); i++) {
+    final int len = auth.length();
+    for (int i = 0; i < len; i++) {
       var c = auth.charAt(i);
       if (!Character.isDefined(c) || Character.isISOControl(c) || c == 
'\uFFFD') {
         return false;
diff --git 
a/core/src/main/java/org/apache/accumulo/access/impl/AccessEvaluatorImpl.java 
b/core/src/main/java/org/apache/accumulo/access/impl/AccessEvaluatorImpl.java
index 6f34a69..c1cbd04 100644
--- 
a/core/src/main/java/org/apache/accumulo/access/impl/AccessEvaluatorImpl.java
+++ 
b/core/src/main/java/org/apache/accumulo/access/impl/AccessEvaluatorImpl.java
@@ -20,6 +20,7 @@ package org.apache.accumulo.access.impl;
 
 import static org.apache.accumulo.access.impl.CharUtils.BACKSLASH;
 import static org.apache.accumulo.access.impl.CharUtils.QUOTE;
+import static org.apache.accumulo.access.impl.CharUtils.isBackslashSymbol;
 import static org.apache.accumulo.access.impl.CharUtils.isQuoteOrSlash;
 import static org.apache.accumulo.access.impl.CharUtils.isQuoteSymbol;
 
@@ -74,7 +75,8 @@ public final class AccessEvaluatorImpl implements 
AccessEvaluator {
 
   public static CharSequence unescape(CharSequence auth) {
     int escapeCharCount = 0;
-    for (int i = 0; i < auth.length(); i++) {
+    final int authLength = auth.length();
+    for (int i = 0; i < authLength; i++) {
       char c = auth.charAt(i);
       if (isQuoteOrSlash(c)) {
         escapeCharCount++;
@@ -86,11 +88,11 @@ public final class AccessEvaluatorImpl implements 
AccessEvaluator {
         throw new IllegalArgumentException("Illegal escape sequence in auth : 
" + auth);
       }
 
-      char[] unescapedCopy = new char[auth.length() - escapeCharCount / 2];
+      char[] unescapedCopy = new char[authLength - escapeCharCount / 2];
       int pos = 0;
-      for (int i = 0; i < auth.length(); i++) {
+      for (int i = 0; i < authLength; i++) {
         char c = auth.charAt(i);
-        if (c == BACKSLASH) {
+        if (isBackslashSymbol(c)) {
           i++;
           c = auth.charAt(i);
           if (!isQuoteOrSlash(c)) {
@@ -120,17 +122,17 @@ public final class AccessEvaluatorImpl implements 
AccessEvaluator {
    */
   public static CharSequence escape(CharSequence auth, boolean shouldQuote) {
     int escapeCount = 0;
-
-    for (int i = 0; i < auth.length(); i++) {
+    final int authLength = auth.length();
+    for (int i = 0; i < authLength; i++) {
       if (isQuoteOrSlash(auth.charAt(i))) {
         escapeCount++;
       }
     }
 
     if (escapeCount > 0 || shouldQuote) {
-      char[] escapedAuth = new char[auth.length() + escapeCount + (shouldQuote 
? 2 : 0)];
+      char[] escapedAuth = new char[authLength + escapeCount + (shouldQuote ? 
2 : 0)];
       int index = shouldQuote ? 1 : 0;
-      for (int i = 0; i < auth.length(); i++) {
+      for (int i = 0; i < authLength; i++) {
         char c = auth.charAt(i);
         if (isQuoteOrSlash(c)) {
           escapedAuth[index++] = BACKSLASH;
diff --git 
a/core/src/main/java/org/apache/accumulo/access/impl/AccessExpressionImpl.java 
b/core/src/main/java/org/apache/accumulo/access/impl/AccessExpressionImpl.java
index da611b6..1da6fb2 100644
--- 
a/core/src/main/java/org/apache/accumulo/access/impl/AccessExpressionImpl.java
+++ 
b/core/src/main/java/org/apache/accumulo/access/impl/AccessExpressionImpl.java
@@ -61,8 +61,8 @@ public final class AccessExpressionImpl extends 
AccessExpression {
     }
 
     boolean needsQuote = false;
-
-    for (int i = 0; i < term.length(); i++) {
+    final int len = term.length();
+    for (int i = 0; i < len; i++) {
       if (!Tokenizer.isValidAuthChar(term.charAt(i))) {
         needsQuote = true;
         break;

Reply via email to