Otp: Remove string concatenation from calculation hot path

Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
This commit is contained in:
Harsh Shandilya 2019-05-31 12:57:39 +05:30
parent 30b6d2346a
commit daafc01ce2
No known key found for this signature in database
GPG key ID: C2E74282C2133D62

View file

@ -43,13 +43,13 @@ public class Otp {
code[0] = (byte) (0x7f & code[0]);
String strCode = new BigInteger(code).toString();
if (digits.equals("s")) {
String output = "";
StringBuilder output = new StringBuilder();
int bigInt = new BigInteger(code).intValue();
for (int i = 0; i != 5; i++) {
output += steam[bigInt % 26];
output.append(steam[bigInt % 26]);
bigInt /= 26;
}
return output;
return output.toString();
}
else return strCode.substring(strCode.length() - Integer.parseInt(digits));
}