Refactored algorithm. Clarified documentation. #7

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
1 participant
@joeyw

joeyw commented May 2, 2012

There was no need for sorting the strings into a specific
order when we just want the longest one. Out of several
methods of determining the longest string, max_by was
chosen; it was the second fastest, chosen because the faster
alternative required extending the Array class with more code.

Refactored the string downcasing to only downcase the longest
string, saving a few cycles since it does not have to transform
the entire sha. This change required modifying the regex that
detected the strings to ignore character case.

These changes provided a slight performance boost and, i think,
slightly more readible code that does what the documentation says
it does.

Benchmark data and code: https://gist.github.com/2572524

Refactored algorithm. Clarified documentation.
There was no need for sorting the strings into a specific
order when we just want the longest one. Out of several
methods of determining the longest string, max_by was
chosen; it was the second fastest, chosen because the faster
alternative required extending the Array class with more code.

Refactored the string downcasing to only downcase the longest
string, saving a few cycles since it does not have to transform
the entire sha. This change required modifying the regex that
detected the strings to ignore character case.

These changes provided a slight performance boost and, i think,
slightly more readible code that does what the documentation says
it does.

Benchmark data and code: https://gist.github.com/2572524

@joeyw joeyw closed this Sep 29, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment