Merge pull request #1412 from Hackerpilot/master

Code cleanup
This commit is contained in:
Andrei Alexandrescu 2013-07-19 15:37:56 -07:00
commit 73c8b59bb5
13 changed files with 72 additions and 75 deletions

View file

@ -1263,12 +1263,12 @@ unittest
static struct S3 static struct S3
{ {
int i; int i;
this(this){}; this(this){}
} }
static struct S4 static struct S4
{ {
int i = 1; int i = 1;
this(this){}; this(this){}
} }
static assert (!hasElaborateAssign!S1); static assert (!hasElaborateAssign!S1);
static assert (!hasElaborateAssign!S2); static assert (!hasElaborateAssign!S2);

View file

@ -723,9 +723,8 @@ struct BitArray
lo++; lo++;
hi--; hi--;
} }
Ldone:
;
} }
Ldone:
return this; return this;
} }

View file

@ -2181,10 +2181,10 @@ Target parse(Target, Source)(ref Source p)
{ {
static import core.stdc.math/* : HUGE_VAL*/; static import core.stdc.math/* : HUGE_VAL*/;
static immutable real negtab[14] = static immutable real[14] negtab =
[ 1e-4096L,1e-2048L,1e-1024L,1e-512L,1e-256L,1e-128L,1e-64L,1e-32L, [ 1e-4096L,1e-2048L,1e-1024L,1e-512L,1e-256L,1e-128L,1e-64L,1e-32L,
1e-16L,1e-8L,1e-4L,1e-2L,1e-1L,1.0L ]; 1e-16L,1e-8L,1e-4L,1e-2L,1e-1L,1.0L ];
static immutable real postab[13] = static immutable real[13] postab =
[ 1e+4096L,1e+2048L,1e+1024L,1e+512L,1e+256L,1e+128L,1e+64L,1e+32L, [ 1e+4096L,1e+2048L,1e+1024L,1e+512L,1e+256L,1e+128L,1e+64L,1e+32L,
1e+16L,1e+8L,1e+4L,1e+2L,1e+1L ]; 1e+16L,1e+8L,1e+4L,1e+2L,1e+1L ];
// static immutable string infinity = "infinity"; // static immutable string infinity = "infinity";
@ -2574,7 +2574,7 @@ unittest
debug(conv) scope(success) writeln("unittest @", __FILE__, ":", __LINE__, " succeeded."); debug(conv) scope(success) writeln("unittest @", __FILE__, ":", __LINE__, " succeeded.");
struct longdouble struct longdouble
{ {
ushort value[5]; ushort[5] value;
} }
real ld; real ld;

View file

@ -430,7 +430,7 @@ unittest
int value; int value;
} }
Layout ans[3]; Layout[3] ans;
ans[0].name = "one"; ans[0].name = "one";
ans[0].value = 1; ans[0].value = 1;
ans[1].name = "two"; ans[1].name = "two";
@ -481,7 +481,7 @@ unittest
double other; double other;
} }
Layout ans[2]; Layout[2] ans;
ans[0].name = "\U00010143Hello"; ans[0].name = "\U00010143Hello";
ans[0].value = 65; ans[0].value = 65;
ans[0].other = 63.63; ans[0].other = 63.63;
@ -528,7 +528,7 @@ unittest
auto records = csvReader!Layout(str, ["b","c","a"]); auto records = csvReader!Layout(str, ["b","c","a"]);
Layout ans[2]; Layout[2] ans;
ans[0].name = "Hello"; ans[0].name = "Hello";
ans[0].value = 65; ans[0].value = 65;
ans[0].other = 63.63; ans[0].other = 63.63;

View file

@ -1402,7 +1402,7 @@ private void formatUnsigned(Writer, Char)(Writer w, ulong arg, ref FormatSpec!Ch
forcedPrefix = '-'; forcedPrefix = '-';
} }
// fill the digits // fill the digits
char buffer[64]; // 64 bits in base 2 at most char[64] buffer; // 64 bits in base 2 at most
char[] digits; char[] digits;
{ {
uint i = buffer.length; uint i = buffer.length;
@ -1592,8 +1592,8 @@ if (is(FloatingPointTypeOf!T) && !is(T == enum) && !hasToString!(T, Char))
} }
} }
if (fs.spec == 's') fs.spec = 'g'; if (fs.spec == 's') fs.spec = 'g';
char sprintfSpec[1 /*%*/ + 5 /*flags*/ + 3 /*width.prec*/ + 2 /*format*/ char[1 /*%*/ + 5 /*flags*/ + 3 /*width.prec*/ + 2 /*format*/
+ 1 /*\0*/] = void; + 1 /*\0*/] sprintfSpec = void;
sprintfSpec[0] = '%'; sprintfSpec[0] = '%';
uint i = 1; uint i = 1;
if (fs.flDash) sprintfSpec[i++] = '-'; if (fs.flDash) sprintfSpec[i++] = '-';

View file

@ -123,8 +123,8 @@ version(unittest)
if (isnan(x) || isnan(y)) if (isnan(x) || isnan(y))
return 0; return 0;
char bufx[30]; char[30] bufx;
char bufy[30]; char[30] bufy;
assert(ndigits < bufx.length); assert(ndigits < bufx.length);
int ix; int ix;
@ -486,8 +486,7 @@ trigerr:
} }
return real.nan; return real.nan;
Lret: Lret: {}
;
} }
else version(D_InlineAsm_X86_64) else version(D_InlineAsm_X86_64)
{ {
@ -535,8 +534,7 @@ trigerr:
} }
return real.nan; return real.nan;
Lret: Lret: {}
;
} }
else else
{ {
@ -546,7 +544,7 @@ Lret:
unittest unittest
{ {
static real vals[][2] = // angle,tan static real[2][] vals = // angle,tan
[ [
[ 0, 0], [ 0, 0],
[ .5, .5463024898], [ .5, .5463024898],
@ -1788,7 +1786,7 @@ real frexp(real value, out int exp) @trusted pure nothrow
unittest unittest
{ {
static real vals[][3] = // x,frexp,exp static real[3][] vals = // x,frexp,exp
[ [
[0.0, 0.0, 0], [0.0, 0.0, 0],
[-0.0, -0.0, 0], [-0.0, -0.0, 0],
@ -1818,7 +1816,7 @@ unittest
static if (real.mant_dig == 64) static if (real.mant_dig == 64)
{ {
static real extendedvals[][3] = [ // x,frexp,exp static real[3][] extendedvals = [ // x,frexp,exp
[0x1.a5f1c2eb3fe4efp+73L, 0x1.A5F1C2EB3FE4EFp-1L, 74], // normal [0x1.a5f1c2eb3fe4efp+73L, 0x1.A5F1C2EB3FE4EFp-1L, 74], // normal
[0x1.fa01712e8f0471ap-1064L, 0x1.fa01712e8f0471ap-1L, -1063], [0x1.fa01712e8f0471ap-1064L, 0x1.fa01712e8f0471ap-1L, -1063],
[real.min_normal, .5, -16381], [real.min_normal, .5, -16381],
@ -1929,7 +1927,7 @@ unittest
unittest unittest
{ {
static real vals[][3] = // value,exp,ldexp static real[3][] vals = // value,exp,ldexp
[ [
[ 0, 0, 0], [ 0, 0, 0],
[ 1, 0, 1], [ 1, 0, 1],
@ -2305,7 +2303,7 @@ real hypot(real x, real y) @safe pure nothrow
unittest unittest
{ {
static real vals[][3] = // x,y,hypot static real[3][] vals = // x,y,hypot
[ [
[ 0.0, 0.0, 0.0], [ 0.0, 0.0, 0.0],
[ 0.0, -0.0, 0.0], [ 0.0, -0.0, 0.0],
@ -4725,7 +4723,7 @@ unittest
{ {
debug (math) printf("math.poly.unittest\n"); debug (math) printf("math.poly.unittest\n");
real x = 3.1; real x = 3.1;
static real pp[] = [56.1, 32.7, 6]; static real[] pp = [56.1, 32.7, 6];
assert( poly(x, pp) == (56.1L + (32.7L + 6L * x) * x) ); assert( poly(x, pp) == (56.1L + (32.7L + 6L * x) * x) );
} }

View file

@ -292,7 +292,7 @@ struct MD5_CTX
*/ */
void finish(ref ubyte[16] digest) /* message digest */ void finish(ref ubyte[16] digest) /* message digest */
{ {
ubyte bits[8] = void; ubyte[8] bits = void;
uint index, padLen; uint index, padLen;
/* Save number of bits */ /* Save number of bits */

View file

@ -2068,7 +2068,7 @@ unittest
["nyuk", "I", "have", "no", "chocolate", "giba"], ["nyuk", "I", "have", "no", "chocolate", "giba"],
["wyda", "I", "have", "I", "have", "have", "I", "have", "hehe"], ["wyda", "I", "have", "I", "have", "have", "I", "have", "hehe"],
0.5); 0.5);
double witness[] = [ 7.0, 4.03125, 0, 0 ]; double[] witness = [ 7.0, 4.03125, 0, 0 ];
foreach (e; sim) foreach (e; sim)
{ {
//writeln(e); //writeln(e);

View file

@ -638,7 +638,7 @@ Parameter for the generator.
upperMask = ~((cast(UIntType) 1u << upperMask = ~((cast(UIntType) 1u <<
(UIntType.sizeof * 8 - (w - r))) - 1), (UIntType.sizeof * 8 - (w - r))) - 1),
lowerMask = (cast(UIntType) 1u << r) - 1; lowerMask = (cast(UIntType) 1u << r) - 1;
static immutable UIntType mag01[2] = [0x0UL, a]; static immutable UIntType[2] mag01 = [0x0UL, a];
ulong y = void; ulong y = void;

View file

@ -648,10 +648,10 @@ enum RegexOption: uint {
nonunicode = 0x8, nonunicode = 0x8,
multiline = 0x10, multiline = 0x10,
singleline = 0x20 singleline = 0x20
}; }
alias TypeTuple!('g', 'i', 'x', 'U', 'm', 's') RegexOptionNames;//do not reorder this list alias TypeTuple!('g', 'i', 'x', 'U', 'm', 's') RegexOptionNames;//do not reorder this list
static assert( RegexOption.max < 0x80); static assert( RegexOption.max < 0x80);
enum RegexInfo : uint { oneShot = 0x80 }; enum RegexInfo : uint { oneShot = 0x80 }
private enum NEL = '\u0085', LS = '\u2028', PS = '\u2029'; private enum NEL = '\u0085', LS = '\u2028', PS = '\u2029';
@ -683,7 +683,7 @@ dchar parseUniHex(Char)(ref Char[] str, size_t maxDigit)
{ {
string[] non_hex = [ "000j", "000z", "FffG", "0Z"]; string[] non_hex = [ "000j", "000z", "FffG", "0Z"];
string[] hex = [ "01", "ff", "00af", "10FFFF" ]; string[] hex = [ "01", "ff", "00af", "10FFFF" ];
int value[] = [ 1, 0xFF, 0xAF, 0x10FFFF ]; int[] value = [ 1, 0xFF, 0xAF, 0x10FFFF ];
foreach(v; non_hex) foreach(v; non_hex)
assert(collectException(parseUniHex(v, v.length)).msg assert(collectException(parseUniHex(v, v.length)).msg
.canFind("invalid escape sequence")); .canFind("invalid escape sequence"));
@ -1400,7 +1400,7 @@ struct Parser(R, bool CTFE = false)
//CodepointSet operations relatively in order of priority //CodepointSet operations relatively in order of priority
enum Operator:uint { enum Operator:uint {
Open = 0, Negate, Difference, SymDifference, Intersection, Union, None Open = 0, Negate, Difference, SymDifference, Intersection, Union, None
}; }
//parse unit of CodepointSet spec, most notably escape sequences and char ranges //parse unit of CodepointSet spec, most notably escape sequences and char ranges
//also fetches next set operation //also fetches next set operation
@ -2022,7 +2022,7 @@ public struct Regex(Char)
end = e; end = e;
} }
@property string front() { return groups[start].name; }; @property string front() { return groups[start].name; }
@property string back() { return groups[end-1].name; } @property string back() { return groups[end-1].name; }
@property bool empty() { return start >= end; } @property bool empty() { return start >= end; }
@property size_t length() { return end - start; } @property size_t length() { return end - start; }
@ -2030,7 +2030,7 @@ public struct Regex(Char)
@property NamedGroupRange save() @property NamedGroupRange save()
{ {
return NamedGroupRange(groups, start, end); return NamedGroupRange(groups, start, end);
}; }
void popFront() { assert(!empty); start++; } void popFront() { assert(!empty); start++; }
void popBack() { assert(!empty); end--; } void popBack() { assert(!empty); end--; }
string opIndex()(size_t i) string opIndex()(size_t i)
@ -2639,7 +2639,7 @@ public:
fChar = re.ir[i].data; fChar = re.ir[i].data;
static if(charSize != 3) static if(charSize != 3)
{ {
Char buf[dchar.sizeof/Char.sizeof]; Char[dchar.sizeof/Char.sizeof] buf;
encode(buf, fChar); encode(buf, fChar);
fChar = buf[0]; fChar = buf[0];
} }

View file

@ -288,7 +288,7 @@ unittest
//{ //{
auto p = toStringz("foo"); auto p = toStringz("foo");
assert(strlen(p) == 3); assert(strlen(p) == 3);
const(char) foo[] = "abbzxyzzy"; const(char)[] foo = "abbzxyzzy";
p = toStringz(foo[3..5]); p = toStringz(foo[3..5]);
assert(strlen(p) == 2); assert(strlen(p) == 2);

View file

@ -2481,4 +2481,4 @@ Lis:
} }
else else
return true; return true;
}; }