Skip to content

Commit

Permalink
little performance fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
firaja committed May 1, 2024
1 parent f60d2e4 commit 7041635
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/main/java/com/password4j/PropertyReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static int readInt(String key, int defaultValue, String message)
LOG.warn(MESSAGE, message, defaultValue, key);
return defaultValue;
}
return Integer.parseInt(readString(key));
return Integer.parseInt(str);
}

static boolean readBoolean(String key, boolean defaultValue)
Expand All @@ -62,7 +62,7 @@ static boolean readBoolean(String key, boolean defaultValue)
{
return defaultValue;
}
return Boolean.parseBoolean(readString(key));
return Boolean.parseBoolean(str);
}

static String readString(String key, String defaultValue, String message)
Expand Down Expand Up @@ -116,7 +116,7 @@ static void init()
String customPath = System.getProperty(CONFIGURATION_KEY, null);

InputStream in;
if (customPath == null || customPath.length() == 0)
if (customPath == null || customPath.isEmpty())
{
in = getResource('/' + FILE_NAME);
}
Expand All @@ -140,7 +140,7 @@ static void init()
}
else
{
LOG.debug("Cannot find any properties file.");
LOG.warn("Cannot find any properties file.");
}

properties = props;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/password4j/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Utils
private static final int[] FROM_BASE64 = new int[256];

private static final AtomicInteger THREAD_COUNTER = new AtomicInteger(1);

static
{
Arrays.fill(FROM_BASE64, -1);
Expand Down Expand Up @@ -373,7 +373,7 @@ static String encodeBase64(byte[] src)
static String encodeBase64(byte[] src, boolean padding)
{
byte[] encoded = encode(src, padding);
return new String(encoded, 0, encoded.length);
return new String(encoded);
}

static byte[] decodeBase64(byte[] src)
Expand Down Expand Up @@ -539,7 +539,7 @@ else if (shiftTo == 12)
return dp;
}

@SuppressWarnings({"removal", "java:S1604"})
@SuppressWarnings({"java:S1604"})
static SecureRandom getInstanceStrong() throws NoSuchAlgorithmException
{
String property = AccessController.doPrivileged(new PrivilegedAction<String>()
Expand All @@ -551,7 +551,7 @@ public String run()
}
});

if ((property == null) || (property.length() == 0))
if ((property == null) || (property.isEmpty()))
{
throw new NoSuchAlgorithmException("Null/empty securerandom.strongAlgorithms Security Property");
}
Expand Down

0 comments on commit 7041635

Please sign in to comment.