Skip to content

Commit

Permalink
more performance fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ikod committed Apr 23, 2016
1 parent 8de0eeb commit 0480664
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
6 changes: 3 additions & 3 deletions source/requests/http.d
Original file line number Diff line number Diff line change
Expand Up @@ -622,9 +622,9 @@ struct Request {
throw new RequestException("Headers length > maxHeadersLength (%d > %d)".format(buffer.length, maxHeadersLength));
}
if ( headersHaveBeenReceived(data, buffer, separator) ) {
auto s = buffer.findSplit(separator);
ResponseHeaders = s[0];
partialBody = s[2];
auto s = buffer.data!(ubyte[]).findSplit(separator);
ResponseHeaders = Buffer!ubyte(s[0]);
partialBody = Buffer!ubyte(s[2]);
receivedBodyLength += partialBody.length;
parseResponseHeaders(ResponseHeaders);
break;
Expand Down
15 changes: 9 additions & 6 deletions source/requests/streams.d
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ class DataPipe(E) : DataPipeIface!E {
}
t.each!(b => buffer.put(b));
}
E[] get() {
E[] get() pure {
if ( buffer.empty ) {
return E[].init;
}
auto res = buffer.data;
buffer = Buffer!E.init;
return res;
}
bool empty() {
bool empty() pure const @safe {
return buffer.empty;
}
void flush() {
Expand Down Expand Up @@ -117,7 +117,7 @@ class Decompressor(E) : DataPipeIface!E {
}
__buff.put(__zlib.uncompress(data));
}
override E[] get() {
override E[] get() pure {
assert(__buff.length);
auto r = __buff.__repr.__buffer[0];
__buff.popFrontN(r.length);
Expand All @@ -143,7 +143,7 @@ class Decompressor(E) : DataPipeIface!E {
debug tracef("empty=%b", __buff.empty);
return __buff.empty;
}
@property auto ref front() {
@property auto ref front() pure const @safe {
debug tracef("front: buff length=%d", __buff.length);
return __buff.front;
}
Expand Down Expand Up @@ -338,17 +338,20 @@ struct Buffer(T) {
this(this) {
__repr = new Repr(__repr);
}
this(U)(U[] data) pure {
put(data);
}
~this() {
__repr = null;
}
auto put(U)(U[] data) {
auto put(U)(U[] data) pure {
if ( data.length == 0 ) {
return this;
}
if ( !__repr ) {
__repr = new Repr;
}
tracef("Append %d bytes", data.length);
debug tracef("Append %d bytes", data.length);
static if (!is(U == T)) {
auto d = castFrom!(U[]).to!(T[])(data);
__repr.__length += d.length;
Expand Down

0 comments on commit 0480664

Please sign in to comment.