[Issue 10717] std.ascii.toLower and toUpper should return char instead of dchar and avoid me to use a bad cast(char)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jul 31 05:15:59 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10717



--- Comment #6 from bearophile_hugs at eml.cc 2013-07-31 05:15:58 PDT ---
(In reply to comment #5)

> Does this fit the bill, or do you see anything else that needs to be addressed?

I have tried it, and the semantics seems OK.


But the implementation is:

auto toLower(C)(C c) if(is(C : dchar)) {
    static if(isScalarType!C)
        return isUpper(c) ? cast(Unqual!C)(c + 'a' - 'A') : cast(Unqual!C)c;
    else
        return toLower!dchar(c);
}


So a call to toLower can cause two function calls. toLower() is a tiny function
that could be called many many times, so perhaps in debug mode (without
inlining) doubling the number of function calls slows down the user code a bit.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list