Skip to content

Commit

Permalink
Implementation simplification for std.conv.parse!bool
Browse files Browse the repository at this point in the history
  • Loading branch information
Poita committed Mar 10, 2014
1 parent 2ae9108 commit ecc2051
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions std/conv.d
Expand Up @@ -1860,30 +1860,18 @@ Target parse(Target, Source)(ref Source s)
{
if (!s.empty)
{
auto c1 = s.front;
if (c1 == 't' || c1 == 'T')
auto c1 = std.ascii.toLower(s.front);
bool result = (c1 == 't');
if (result || c1 == 'f')
{
s.popFront();
foreach (c; "rue")
foreach (c; result ? "rue" : "alse")
{
if (!s.empty && std.ascii.toLower(s.front) == c)
s.popFront();
else
goto Lerr;
}
return true;
}
else if (c1 == 'f' || c1 == 'F')
{
s.popFront();
foreach (c; "alse")
{
if (!s.empty && std.ascii.toLower(s.front) == c)
s.popFront();
else
if (s.empty || std.ascii.toLower(s.front) != c)
goto Lerr;
s.popFront();
}
return false;
return result;
}
}
Lerr:
Expand Down

0 comments on commit ecc2051

Please sign in to comment.