Boo
  1. Boo
  2. BOO-137

optimize for item in array construct

    Details

    • Type: Improvement Improvement
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.7.6
    • Component/s: Compiler
    • Labels:
      None
    • Number of attachments :
      1

      Description

      The current progress in the generators front required deoptimizing the handling of "for item in array" constructs.

      for item in array:
      pass

      should expand to:

      i = 0
      while i < len(array):
      item = array[i]
      ++i

      instead of today's:

      iterator = array.GetEnumerator()
      while iterator.MoveNext():
      item = iterator.Current

        Issue Links

          Activity

          Hide
          Cameron Kenneth Knight added a comment -

          Alright, I have done all the tests and everything, and it's all peachy now with the new attachment.

          Show
          Cameron Kenneth Knight added a comment - Alright, I have done all the tests and everything, and it's all peachy now with the new attachment.
          Hide
          Rodrigo B. de Oliveira added a comment -

          6 test cases are still failing after I apply the patch but I'll be giving a throughout review later after this release.

          Thanks!

          Show
          Rodrigo B. de Oliveira added a comment - 6 test cases are still failing after I apply the patch but I'll be giving a throughout review later after this release. Thanks!
          Hide
          Cameron Kenneth Knight added a comment -

          Here's a version that makes it look like other Boo files, e.g. UTF-8 and proper indentation.

          Please tell me what tests it failed on. I ran a lot of tests, and didn't have a problem.

          Show
          Cameron Kenneth Knight added a comment - Here's a version that makes it look like other Boo files, e.g. UTF-8 and proper indentation. Please tell me what tests it failed on. I ran a lot of tests, and didn't have a problem.
          Hide
          Cameron Kenneth Knight added a comment -

          Alright, the file I attached fixed all the errors coming up from `nant test`
          Now, it doesn't support multidimensional arrays (yet).
          It also doesn't support callables, because it's in a hazy place in between when all the entities are declared, but before the callables are expanded.
          I plan on making multidimensional arrays work.
          If one were to have an array of callable types, one would generally not going to be dealing with large arrays that need strict optimization.

          Show
          Cameron Kenneth Knight added a comment - Alright, the file I attached fixed all the errors coming up from `nant test` Now, it doesn't support multidimensional arrays (yet). It also doesn't support callables, because it's in a hazy place in between when all the entities are declared, but before the callables are expanded. I plan on making multidimensional arrays work. If one were to have an array of callable types, one would generally not going to be dealing with large arrays that need strict optimization.
          Hide
          Cameron Kenneth Knight added a comment -

          Here's an updated patch.
          When incrementing by step, it now uses add instead of add.ovf. The overflow checking is unnecessary in that case, because the max already exists.
          Also, when available, it will replace num != end with num < end or num > end.
          This gives it the same IL as C#'s.

          Show
          Cameron Kenneth Knight added a comment - Here's an updated patch. When incrementing by step, it now uses add instead of add.ovf. The overflow checking is unnecessary in that case, because the max already exists. Also, when available, it will replace num != end with num < end or num > end. This gives it the same IL as C#'s.

            People

            • Assignee:
              Cameron Kenneth Knight
              Reporter:
              Rodrigo B. de Oliveira
            • Votes:
              1 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: