dcv icon indicating copy to clipboard operation
dcv copied to clipboard

~= concatenation should be removed

Open 9il opened this issue 9 years ago • 2 comments

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 avatar Oct 02 '16 17:10 9il

Will refactor it in #58. Thank you.

ljubobratovicrelja avatar Oct 02 '16 18:10 ljubobratovicrelja

Please see aead0ada816b9b6c025f0df7cdf9a1fd96e732eb.

ljubobratovicrelja avatar Oct 02 '16 19:10 ljubobratovicrelja