Minor performance optimization

This commit is contained in:
Andrii Shvaika 2023-05-03 16:27:41 +03:00
parent 87bcaabad5
commit f969f07f2f

View File

@ -51,6 +51,10 @@ public class KvUtils {
throw new DataValidationException("Key can't be null"); throw new DataValidationException("Key can't be null");
} }
if (key.length() > 255) {
throw new DataValidationException("Validation error: key length must be equal or less than 255");
}
if (validatedKeys.getIfPresent(key) != null) { if (validatedKeys.getIfPresent(key) != null) {
return; return;
} }
@ -58,9 +62,6 @@ public class KvUtils {
if (!NoXssValidator.isValid(key)) { if (!NoXssValidator.isValid(key)) {
throw new DataValidationException("Validation error: key is malformed"); throw new DataValidationException("Validation error: key is malformed");
} }
if (key.length() > 255) {
throw new DataValidationException("Validation error: key length must be equal or less than 255");
}
validatedKeys.put(key, Boolean.TRUE); validatedKeys.put(key, Boolean.TRUE);
} }