Path as an object in std.path
Dylan Knutson
tcdknutson at gmail.com
Thu Jun 6 09:14:30 PDT 2013
On Thursday, 6 June 2013 at 16:06:50 UTC, Lars T. Kyllingstad
wrote:
> On Thursday, 6 June 2013 at 14:51:13 UTC, Dylan Knutson wrote:
>> I should have said "makes it easier to be platform
>> independent". Normalization is done automatically on
>> comparison.
>
> Yes, p1 == p2 sure looks nice, but unbeknownst to the API user,
> it comes at the cost of several memory allocations, and it does
> not perform a case-insensitive comparison on Windows in its
> current form. (Should it? I dunno.)
It doesn't do any allocations that the user won't have to do
anyways. Paths have to be normalized before comparison; not doing
so isn't correct behavior. Eg, the strings `foo../bar` != `bar`,
yet they're equivalent paths. Path encapsulates the behavior. So
it's the difference between
buildNormalizedPath(s1) == buildNormalizedPath(s2);
and
p1 == p2;
More information about the Digitalmars-d
mailing list