Skip to content

Commit

Permalink
Merge pull request #4622 from JackStouffer/immutable2
Browse files Browse the repository at this point in the history
[trivial] Added const and immutable to several variables in std.net.curl
  • Loading branch information
WalterBright committed Jul 21, 2016
2 parents 48db636 + 96b0a5a commit c06d9f5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
19 changes: 9 additions & 10 deletions std/net/curl.d
Original file line number Diff line number Diff line change
Expand Up @@ -1978,7 +1978,7 @@ private mixin template Protocol()
/// ditto
@property void netInterface(const(ubyte)[4] i)
{
auto str = format("%d.%d.%d.%d", i[0], i[1], i[2], i[3]);
const str = format("%d.%d.%d.%d", i[0], i[1], i[2], i[3]);
netInterface = str;
}

Expand Down Expand Up @@ -2195,7 +2195,7 @@ decodeString(Char = char)(const(ubyte)[] data,
size_t maxChars = size_t.max)
{
Char[] res;
auto startLen = data.length;
immutable startLen = data.length;
size_t charsDecoded = 0;
while (data.length && charsDecoded < maxChars)
{
Expand Down Expand Up @@ -2238,8 +2238,8 @@ private bool decodeLineInto(Terminator, Char = char)(ref const(ubyte)[] basesrc,
if (basesrc.length != 0)
{
// Try to ensure 4 entries in the basesrc by copying from src.
auto blen = basesrc.length;
size_t len = (basesrc.length + src.length) >= 4 ?
immutable blen = basesrc.length;
immutable len = (basesrc.length + src.length) >= 4 ?
4 : basesrc.length + src.length;
basesrc.length = len;

Expand All @@ -2256,7 +2256,7 @@ private bool decodeLineInto(Terminator, Char = char)(ref const(ubyte)[] basesrc,

while (src.length)
{
auto lsrc = src;
const lsrc = src;
dchar dc = scheme.safeDecode(src);
if (dc == INVALID_SEQUENCE)
{
Expand Down Expand Up @@ -2371,10 +2371,9 @@ struct HTTP
}
if (header.startsWith("HTTP/"))
{
string[string] empty;
headersIn = empty; // clear
headersIn.clear();

auto m = match(header, regex(r"^HTTP/(\d+)\.(\d+) (\d+) (.*)$"));
const m = match(header, regex(r"^HTTP/(\d+)\.(\d+) (\d+) (.*)$"));
if (m.empty)
{
// Invalid status line
Expand Down Expand Up @@ -4732,8 +4731,8 @@ private static void _spawnAsync(Conn, Unit, Terminator = void)()
static if ( !is(Terminator == void))
{
// Only lines reading will receive a terminator
auto terminator = receiveOnly!Terminator();
auto keepTerminator = receiveOnly!bool();
const terminator = receiveOnly!Terminator();
const keepTerminator = receiveOnly!bool();

// max number of bytes to carry over from an onReceive
// callback. This is 4 because it is the max code units to
Expand Down
8 changes: 4 additions & 4 deletions std/regex/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ private:
_f = 0;
}

@property Group!DataIndex[] matches()
@property inout(Group!DataIndex[]) matches() inout
{
return (_refcount & SMALL_MASK) ? small_matches[0 .. _refcount & 0xFF] : big_matches;
}
Expand Down Expand Up @@ -557,7 +557,7 @@ public:
@property bool empty() const { return _nMatch == 0 || _f >= _b; }

///ditto
R opIndex()(size_t i) /*const*/ //@@@BUG@@@
inout(R) opIndex()(size_t i) inout
{
assert(_f + i < _b,text("requested submatch number ", i," is out of range"));
assert(matches[_f + i].begin <= matches[_f + i].end,
Expand Down Expand Up @@ -761,13 +761,13 @@ public:
auto save(){ return this; }

///Test if this match object is empty.
@property bool empty(){ return _captures._nMatch == 0; }
@property bool empty() const { return _captures._nMatch == 0; }

///Same as !(x.empty), provided for its convenience in conditional statements.
T opCast(T:bool)(){ return !empty; }

/// Same as .front, provided for compatibility with original std.regex.
@property auto captures(){ return _captures; }
@property auto captures() inout { return _captures; }

}

Expand Down

0 comments on commit c06d9f5

Please sign in to comment.