Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

~= concatenation should be removed #66

Open
9il opened this issue Oct 2, 2016 · 2 comments
Open

~= concatenation should be removed #66

9il opened this issue Oct 2, 2016 · 2 comments

Comments

@9il
Copy link
Member

9il commented Oct 2, 2016

From RHT module:

    /// Run RHT using non-zero points in image as edge points.
    auto opCall(T)(Slice!(2, T*) image)
    {
        Point[] points;
        foreach (y; 0 .. image.length!0)
            foreach (x; 0 .. image.length!1)
            {
                if (image[y, x] > 0)
                {
                    points ~= Point(cast(int)x, cast(int)y);
                }
            }
        return this.opCall(image, points);
    }

This example has 2 issue. The first is slow indexing. The second is ~= concatenation, which changes complexity from O(n) to O(n^2).

@9il 9il changed the title ~= concatenation is evil ~= concatenation should be removed Oct 2, 2016
@ljubobratovicrelja
Copy link
Member

Will refactor it in #58. Thank you.

@ljubobratovicrelja
Copy link
Member

Please see aead0ad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants