From daafc01ce232205096675afa20ab4982209689aa Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Fri, 31 May 2019 12:57:39 +0530 Subject: Otp: Remove string concatenation from calculation hot path Signed-off-by: Harsh Shandilya --- app/src/main/java/com/zeapo/pwdstore/utils/Otp.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/src/main/java/com/zeapo/pwdstore/utils/Otp.java b/app/src/main/java/com/zeapo/pwdstore/utils/Otp.java index 0bacd684..2e6bebd6 100644 --- a/app/src/main/java/com/zeapo/pwdstore/utils/Otp.java +++ b/app/src/main/java/com/zeapo/pwdstore/utils/Otp.java @@ -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)); } -- cgit v1.2.3