Skip to content

Contour perf: get rid of join(',') #1311

Closed

Description

@alexcjohnson

In our marching squares algorithm, we have a lot of statements that amount to indicesStr = indices.join(','). These make the code a little clearer (you can do a single === to find out if two locations are the same) but have a substantial perf cost:

timeit(function(v) { return v.join(',') === '2,2'; }, [2,3], 1000000)
0.00024889000000001397

timeit(function(v) { return v[0] === 2 && v[1] === 2; }, [2,3], 1000000)
0.000011064999999944121

Lets replace them with straight-up integer comparisons.

Activity

  1. added 3 commits that reference this issue on Aug 2, 2019
    ee43055
    006ddc7
    b81f017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions