June 23, 2006 Bugzilla #113 fix - ineffective code (dmd161) | ||||
---|---|---|---|---|
| ||||
Although working - the fix to bug #113 contains partly ineffective code starting at line #875 of dmd161's "src\phobos\std\format.d". It might be worthwhile to consider re-using original code to fix bug #113. This would more in line with subsequent code found in the std.format module: ----------- ##### Original - starting at line # 866 (as of dmd 161): if (vnumber < base) { if (vnumber == 0 && precision == 0 && flags & FLprecision && !(fc == 'o' && flags & FLhash)) { putstr(null); return; } if (precision == 0 || !(flags & FLprecision)) { vchar = '0' + vnumber; if (vnumber < 10) vchar = '0' + vnumber; else vchar = (uc ? 'A' - 10 : 'a' - 10) + vnumber; goto L2; } } int n = tmpbuf.length; char c; int hexoffset = uc ? ('A' - ('9' + 1)) : ('a' - ('9' + 1)); ----------- ##### Proposed changes: int hexoffset = uc ? ('A' - ('9' + 1)) : ('a' - ('9' + 1)); if (vnumber < base) { if (vnumber == 0 && precision == 0 && flags & FLprecision && !(fc == 'o' && flags & FLhash)) { putstr(null); return; } if (precision == 0 || !(flags & FLprecision)) { vchar = '0' + vnumber; if (vnumber > 9) vchar += hexoffset; goto L2; } } int n = tmpbuf.length; char c; ----------- Note: The line containing "int hexoffset = ..." needs to be moved up to line 866, then hexoffset can be used the same way as it is done already in subsequent parts of the module's code. |
Copyright © 1999-2021 by the D Language Foundation