You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2014/02/06 18:32:21 UTC
[11/12] couch-httpd commit: updated refs/heads/import-rcouch to
5b12577
Speed up and move couch_httpd:find_in_binary.
See https://issues.apache.org/jira/browse/COUCHDB-1953
Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/commit/93c8402f
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/tree/93c8402f
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/diff/93c8402f
Branch: refs/heads/import-rcouch
Commit: 93c8402f36b36d14c144d590ab9a831db703d151
Parents: e57f0a9
Author: NickNorth <No...@gmail.com>
Authored: Tue Dec 3 20:58:53 2013 +0000
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Thu Feb 6 11:31:05 2014 -0600
----------------------------------------------------------------------
src/couch_httpd.erl | 30 +-----------------------------
1 file changed, 1 insertion(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/blob/93c8402f/src/couch_httpd.erl
----------------------------------------------------------------------
diff --git a/src/couch_httpd.erl b/src/couch_httpd.erl
index 7be8a2a..29f9db0 100644
--- a/src/couch_httpd.erl
+++ b/src/couch_httpd.erl
@@ -968,7 +968,7 @@ split_header(Line) ->
mochiweb_util:parse_header(Value)}].
read_until(#mp{data_fun=DataFun, buffer=Buffer}=Mp, Pattern, Callback) ->
- case find_in_binary(Pattern, Buffer) of
+ case couch_util:find_in_binary(Pattern, Buffer) of
not_found ->
Callback2 = Callback(Buffer),
{Buffer2, DataFun2} = DataFun(),
@@ -1044,34 +1044,6 @@ check_for_last(#mp{buffer=Buffer, data_fun=DataFun}=Mp) ->
data_fun = DataFun2})
end.
-find_in_binary(_B, <<>>) ->
- not_found;
-
-find_in_binary(B, Data) ->
- case binary:match(Data, [B], []) of
- nomatch ->
- partial_find(binary:part(B, {0, byte_size(B) - 1}),
- binary:part(Data, {byte_size(Data), -byte_size(Data) + 1}), 1);
- {Pos, _Len} ->
- {exact, Pos}
- end.
-
-partial_find(<<>>, _Data, _Pos) ->
- not_found;
-
-partial_find(B, Data, N) when byte_size(Data) > 0 ->
- case binary:match(Data, [B], []) of
- nomatch ->
- partial_find(binary:part(B, {0, byte_size(B) - 1}),
- binary:part(Data, {byte_size(Data), -byte_size(Data) + 1}), N + 1);
- {Pos, _Len} ->
- {partial, N + Pos}
- end;
-
-partial_find(_B, _Data, _N) ->
- not_found.
-
-
validate_bind_address(Address) ->
case inet_parse:address(Address) of
{ok, _} -> ok;