[distances] Don't concat two strings to know if there is a space in one of them. Make two tests instead
authorSimon Chabot <simon.chabot@logilab.fr>
Mon, 29 Oct 2012 09:46:26 +0100
changeset 55 abb7cb198f25
parent 54 3b6ddfafa6b3
child 56 afa74864fe6c
[distances] Don't concat two strings to know if there is a space in one of them. Make two tests instead
distances.py
--- a/distances.py	Fri Oct 26 11:44:50 2012 +0200
+++ b/distances.py	Mon Oct 29 09:46:26 2012 +0100
@@ -32,7 +32,7 @@
             _handlespaces(stra, strb), levenshtein)
     """
 
-    if ' ' in (stra + strb):
+    if ' ' in stra or ' ' in strb:
         return _handlespaces(stra, strb, levenshtein)
 
     lena = len(stra)
@@ -147,7 +147,7 @@
     """ Return the 1/0 distance between the soundex code of stra and strb.
         0 means they have the same code, 1 they don't
     """
-    if ' ' in (stra + strb):
+    if ' ' in stra or ' ' in strb:
         return _handlespaces(stra, strb, soundex, language = language)
 
     return 0 if (soundexcode(stra, language) == soundexcode(strb, language)) \