Lichen

Changeset

832:ed201ad4d8e1
2018-06-24 Paul Boddie raw files shortlog changelog graph Moved next method retrieval outside "for" loop bodies. Due to alias-related improvements, the temporary name providing access to the method should yield reference information and cause the method to be efficiently invoked.
common.py (file)
     1.1 --- a/common.py	Sun Jun 24 18:43:57 2018 +0200
     1.2 +++ b/common.py	Sun Jun 24 18:47:03 2018 +0200
     1.3 @@ -552,6 +552,8 @@
     1.4          self.next_temporary()
     1.5          t1 = self.get_temporary_name()
     1.6          self.next_temporary()
     1.7 +        t2 = self.get_temporary_name()
     1.8 +        self.next_temporary()
     1.9  
    1.10          node = compiler.ast.Stmt([
    1.11  
    1.12 @@ -568,13 +570,18 @@
    1.13                      compiler.ast.Getattr(compiler.ast.Name(t0), "__iter__"),
    1.14                      [])),
    1.15  
    1.16 +            # <t2> = <t1>.next
    1.17              # try:
    1.18              #     while True:
    1.19 -            #         <var>... = <t1>.next()
    1.20 +            #         <var>... = <t2>()
    1.21              #         ...
    1.22              # except StopIteration:
    1.23              #     pass
    1.24  
    1.25 +            compiler.ast.Assign(
    1.26 +                [compiler.ast.AssName(t2, "OP_ASSIGN")],
    1.27 +                compiler.ast.Getattr(compiler.ast.Name(t1), "next")),
    1.28 +
    1.29              compiler.ast.TryExcept(
    1.30                  compiler.ast.While(
    1.31                      compiler.ast.Name("True"),
    1.32 @@ -582,7 +589,7 @@
    1.33                          compiler.ast.Assign(
    1.34                              [n.assign],
    1.35                              compiler.ast.CallFunc(
    1.36 -                                compiler.ast.Getattr(compiler.ast.Name(t1), "next"),
    1.37 +                                compiler.ast.Name(t2),
    1.38                                  []
    1.39                                  )),
    1.40                          n.body]),