]> git.mxchange.org Git - juser-login-core.git/commitdiff
Use string builder
authorRoland Haeder <roland@mxchange.org>
Wed, 13 Apr 2016 21:10:14 +0000 (23:10 +0200)
committerRoland Haeder <roland@mxchange.org>
Wed, 13 Apr 2016 21:10:14 +0000 (23:10 +0200)
src/org/mxchange/jusercore/model/user/UserUtils.java

index 486e20f291a4bf8c4dc3a0431be8eeec7cfbed17..740e7e3927ba2729c58905b4559ca34b21823cc8 100644 (file)
@@ -71,7 +71,7 @@ public class UserUtils extends BaseFrameworkSystem {
                }
 
                // Init variable
-               String password = "";
+               StringBuilder password = new StringBuilder(length);
 
                // Start creating it
                for (int i = 0; i < length; i++) {
@@ -79,14 +79,14 @@ public class UserUtils extends BaseFrameworkSystem {
                        int pos = RANDOM_NUMBER_GENERATOR.nextInt(PASSWORD_ALPHABET.length());
 
                        // Get char at this position and add it to the final password
-                       password += String.valueOf(PASSWORD_ALPHABET.charAt(pos));
+                       password.append(String.valueOf(PASSWORD_ALPHABET.charAt(pos)));
                }
 
                // Should have the wanted length
                assert (password.length() == length) : "Password length " + password.length() + " doesn't match requested: " + length;
 
                // Return it
-               return password;
+               return password.toString();
        }
 
        /**