http://d.puremagic.com/issues/show_bug.cgi?id=10717
--- Comment #7 from [email protected] 2013-07-31 12:26:58 PDT --- (In reply to comment #6) > 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. Well, it can cause two function calls only for user defined types, so the case should not be that common. Doing it this way means you'll only end up instanciating `toLower!dchar` for all user types. Which is also a plus. One of the implementation I had suggested was: ////-------- //Public template that only filters and changes return type auto toUpper(C)(C c) @safe pure nothrow if (is(C : dchar)) out(result) { assert(!isLower(result)); } body { alias Ret = Select!(isScalarType!C, C, dchar); return cast(Ret) toUpperImpl(c); } //Non template that does actual job. private dchar toUpperImpl(dchar c) @safe pure nothrow { return isLower(c) ? cast(dchar)(c - ('a' - 'A')) : c; } ////-------- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
