- Notifications
You must be signed in to change notification settings - Fork20k
Efficiency#732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Efficiency#732
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Just two small things that in case the number was very big could be helpful.
I have been testing both ways to do it measuring time. Both are very fast and truly this pull request doesn't fix anything very important, but when the computer is working in other things and interrupts the thread, in your case you have a small delay. On the other hand, my solution makes it an atomic operation. |
ciphers/Caesar.java Outdated
@@ -24,8 +24,8 @@ | |||
public static String encode(String message, int shift) { | |||
String encoded = ""; | |||
while (shift >= 26) { // 26 = number of latin letters | |||
shift -= 26; | |||
if (shift >= 26) { // 26 = number of latin letters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Good catch! In fact, even thisif
is not necessary, since the modulo operation is no-op ifshift
< 26, i.e.
shift % 26 == shift
if 0 <=shift
< 26
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Oh! That's true! Less code then :)
havanagrawal commentedMay 2, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
LGTM :) |
Just two small things that in case the number was very big could be helpful.