summaryrefslogtreecommitdiff
path: root/sphinx/versioning.py
diff options
context:
space:
mode:
authorDaniel Neuhäuser <ich@danielneuhaeuser.de>2010-08-15 21:06:47 +0200
committerDaniel Neuhäuser <ich@danielneuhaeuser.de>2010-08-15 21:06:47 +0200
commitad5b5c740b3c6af1f6a84af7bfa9f41f6c9c69d2 (patch)
tree3ba547807bddee712647337635feb417ce48f8d9 /sphinx/versioning.py
parentc3905938eaa5762d9e407e0cc31616b757562be8 (diff)
downloadsphinx-git-ad5b5c740b3c6af1f6a84af7bfa9f41f6c9c69d2.tar.gz
Make levenshtein implementation faster for equal strings
Diffstat (limited to 'sphinx/versioning.py')
-rw-r--r--sphinx/versioning.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/sphinx/versioning.py b/sphinx/versioning.py
index 0b2b1f24f..753629042 100644
--- a/sphinx/versioning.py
+++ b/sphinx/versioning.py
@@ -66,12 +66,11 @@ def get_ratio(old, new):
Returns a "similiarity ratio" representing the similarity between the two
strings where 0 is equal and anything above less than equal.
"""
- if old == new:
- return 0
- ratio = levenshtein_distance(old, new) / (len(old) / 100.0)
- return ratio
+ return levenshtein_distance(old, new) / (len(old) / 100.0)
def levenshtein_distance(a, b):
+ if a == b:
+ return 0
if len(a) < len(b):
a, b = b, a
if not a: