From bc503d1e90fac2baf8f3f115692c9ac940e9d5bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Thu, 25 Mar 2004 13:50:59 +0000 Subject: Use True/False instead of 0/1 for character classes. --- Lib/sre_compile.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Lib/sre_compile.py b/Lib/sre_compile.py index ee0882d..1d5dae3 100644 --- a/Lib/sre_compile.py +++ b/Lib/sre_compile.py @@ -193,16 +193,16 @@ def _compile_charset(charset, flags, code, fixup=None): def _optimize_charset(charset, fixup): # internal: optimize character set out = [] - charmap = [0]*256 + charmap = [False]*256 try: for op, av in charset: if op is NEGATE: out.append((op, av)) elif op is LITERAL: - charmap[fixup(av)] = 1 + charmap[fixup(av)] = True elif op is RANGE: for i in range(fixup(av[0]), fixup(av[1])+1): - charmap[i] = 1 + charmap[i] = True elif op is CATEGORY: # XXX: could append to charmap tail return charset # cannot compress @@ -286,17 +286,17 @@ def _optimize_unicode(charset, fixup): import array except ImportError: return charset - charmap = [0]*65536 + charmap = [False]*65536 negate = 0 try: for op, av in charset: if op is NEGATE: negate = 1 elif op is LITERAL: - charmap[fixup(av)] = 1 + charmap[fixup(av)] = True elif op is RANGE: for i in range(fixup(av[0]), fixup(av[1])+1): - charmap[i] = 1 + charmap[i] = True elif op is CATEGORY: # XXX: could expand category return charset # cannot compress -- cgit v0.12