SketchUp / sketchup-annotations

MIT License
0 stars 1 forks source link

Perhaps simplify nested iteration in `AnnotationEraserTool#erase_annotation_at()` #2

Open DanRathbun opened 1 year ago

DanRathbun commented 1 year ago

Perhaps simplify nested iteration in AnnotationEraserTool#erase_annotation_at()

https://github.com/SketchUp/sketchup-annotations/blob/main/src/su_annotations/tools/annotation_eraser.rb erase_annotation_at(), line 197, is a somewhat confusing nested iteration ...

      indicies = {}
      @curves.each { |type, curves|
        indicies[type] = []
        curves.each { |data|
          indicies[type] << data[:index]
        }
      }

... which might be simplified to ...

      indicies = @curves.map { |type, curves|
        [ type, curves.map { |data| data[:index] } ]
      }