Initial feedback for std.experimental.image
ponce via Digitalmars-d
digitalmars-d at puremagic.com
Tue Jul 7 05:10:07 PDT 2015
On Tuesday, 7 July 2015 at 08:50:45 UTC, Manu wrote:
> Most iterators are already size_t.
.length should have been int but it's too late.
It's not because it's a "size" that it should be size_t.
> Indexes shoulds be size_t for conventions sake, otherwise you
> cast everywhere.
Disagree. I think it's the other way around.
And image coordinates are not especially indices.
> Indices should be unsigned, otherwise you need to do 2 tests for
> validity, rather than just one; (x >= 0 && x < length) rather
> than
> just (x < length).
You can force an unsigned comparison with (cast(uint)x < length).
Signed indices optimize better in loops because signed overflow
is undefined behaviour.
http://stackoverflow.com/questions/18795453/why-prefer-signed-over-unsigned-in-c
More information about the Digitalmars-d
mailing list