consecutive HASH_STOP chars at start shouldn't count as a stop

This commit is contained in:
jesopo 2019-11-19 14:45:47 +00:00
parent 554f21a84c
commit bd176240d6

View file

@ -46,8 +46,11 @@ HASH_COLORS = [consts.CYAN, consts.PURPLE, consts.GREEN, consts.ORANGE,
consts.LIGHTGREEN, consts.BLUE] consts.LIGHTGREEN, consts.BLUE]
def hash_colorize(s: str): def hash_colorize(s: str):
hash = 5381 hash = 5381
non_stop = False
for i, char in enumerate(s): for i, char in enumerate(s):
if char in HASH_STOP and i > 0: if not char in HASH_STOP:
non_stop = True
elif non_stop:
break break
hash ^= ((hash<<5)+(hash>>2)+ord(char))&0xFFFFFFFFFFFFFFFF hash ^= ((hash<<5)+(hash>>2)+ord(char))&0xFFFFFFFFFFFFFFFF