diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-04-11 16:21:51 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-04-11 16:21:51 (GMT) |
commit | 5af105eec996a86500d0b1e81379308b86ec4e38 (patch) | |
tree | bd69df6a626a858533b661352c3fa7a5ef5557ed | |
parent | ceccc3c0376671ee1da9714bbe15d1fae436c66c (diff) | |
download | cpython-5af105eec996a86500d0b1e81379308b86ec4e38.zip cpython-5af105eec996a86500d0b1e81379308b86ec4e38.tar.gz cpython-5af105eec996a86500d0b1e81379308b86ec4e38.tar.bz2 |
Make sure the docstring is always entered as the first element in the
consts, even if it is None.
Simplify _lookupName() by removing lots of redundant tests.
-rw-r--r-- | Lib/compiler/pyassem.py | 12 | ||||
-rw-r--r-- | Tools/compiler/compiler/pyassem.py | 12 |
2 files changed, 2 insertions, 22 deletions
diff --git a/Lib/compiler/pyassem.py b/Lib/compiler/pyassem.py index 9f9e904..43bf6f4 100644 --- a/Lib/compiler/pyassem.py +++ b/Lib/compiler/pyassem.py @@ -254,7 +254,6 @@ class PyFlowGraph(FlowGraph): def setDocstring(self, doc): self.docstring = doc - self.consts.insert(0, doc) def setFlag(self, flag): self.flags = self.flags | flag @@ -335,6 +334,7 @@ class PyFlowGraph(FlowGraph): def convertArgs(self): """Convert arguments from symbolic to concrete form""" assert self.stage == FLAT + self.consts.insert(0, self.docstring) for i in range(len(self.insts)): t = self.insts[i] if len(t) == 2: @@ -347,21 +347,11 @@ class PyFlowGraph(FlowGraph): def _lookupName(self, name, list): """Return index of name in list, appending if necessary""" - found = None t = type(name) for i in range(len(list)): # must do a comparison on type first to prevent UnicodeErrors if t == type(list[i]) and list[i] == name: - found = 1 - break - if found: - # this is cheap, but incorrect in some cases, e.g 2 vs. 2L - if type(name) == type(list[i]): return i - for i in range(len(list)): - elt = list[i] - if type(elt) == type(name) and elt == name: - return i end = len(list) list.append(name) return end diff --git a/Tools/compiler/compiler/pyassem.py b/Tools/compiler/compiler/pyassem.py index 9f9e904..43bf6f4 100644 --- a/Tools/compiler/compiler/pyassem.py +++ b/Tools/compiler/compiler/pyassem.py @@ -254,7 +254,6 @@ class PyFlowGraph(FlowGraph): def setDocstring(self, doc): self.docstring = doc - self.consts.insert(0, doc) def setFlag(self, flag): self.flags = self.flags | flag @@ -335,6 +334,7 @@ class PyFlowGraph(FlowGraph): def convertArgs(self): """Convert arguments from symbolic to concrete form""" assert self.stage == FLAT + self.consts.insert(0, self.docstring) for i in range(len(self.insts)): t = self.insts[i] if len(t) == 2: @@ -347,21 +347,11 @@ class PyFlowGraph(FlowGraph): def _lookupName(self, name, list): """Return index of name in list, appending if necessary""" - found = None t = type(name) for i in range(len(list)): # must do a comparison on type first to prevent UnicodeErrors if t == type(list[i]) and list[i] == name: - found = 1 - break - if found: - # this is cheap, but incorrect in some cases, e.g 2 vs. 2L - if type(name) == type(list[i]): return i - for i in range(len(list)): - elt = list[i] - if type(elt) == type(name) and elt == name: - return i end = len(list) list.append(name) return end |