Permalink
Browse files

cosocket: did a minor optimization for receiveuntil patterns no longe…

…r than 2 bytes.
  • Loading branch information...
1 parent 7a4cbfb commit e60a94814583b4c716b8511907bfc7c6321904fa @agentzh agentzh committed Jan 24, 2012
Showing with 24 additions and 13 deletions.
  1. +20 −13 misc/recv-until-pm/t/sanity.t
  2. +4 −0 src/ngx_http_lua_socket.c
@@ -35,97 +35,104 @@ __DATA__
=== TEST 3:
+--- pat: ab
+--- txt: bbcabcaad
+--- out: bbc
+
+
+
+=== TEST 4:
--- pat: aaa
--- txt: abaabcaaaef
--- out: abaabc
-=== TEST 4:
+=== TEST 5:
--- pat: aaaaad
--- txt: baaaaaaaaeaaaaaaadf
--- out: baaaaaaaaeaa
-=== TEST 5:
+=== TEST 6:
--- pat: abacadae
--- txt: a
--- out:
-=== TEST 6:
+=== TEST 7:
--- pat: abacadae
--- txt: ababacadae
--- out: ab
-=== TEST 7:
+=== TEST 8:
--- pat: abacadae
--- txt: abacabacadae
--- out: abac
-=== TEST 8:
+=== TEST 9:
--- pat: abacadae
--- txt: abaabacadae
--- out: aba
-=== TEST 9:
+=== TEST 10:
--- pat: abacadae
--- txt: abacadabacadae
--- out: abacad
-=== TEST 10:
+=== TEST 11:
--- pat: abcabdabcabe
--- txt: abcabdabcabdabcabe
--- out: abcabd
-=== TEST 11:
+=== TEST 12:
--- pat: abcabdabcabe
--- txt: abcabdabcabcabdabcabe
--- out: abcabdabc
-=== TEST 12:
+=== TEST 13:
--- pat: abcabdabcabe
--- txt: abcabcabdabcabe
--- out: abc
-=== TEST 13:
+=== TEST 14:
--- pat: abcabdabcabe
--- txt: ababcabdabcabe
--- out: ab
-=== TEST 14:
+=== TEST 15:
--- pat: abcdef
--- txt: abcabcdef
--- out: abc
-=== TEST 15:
+=== TEST 16:
--- pat: -- abc
--- txt: ---- abc
--- out: --
-=== TEST 16:
+=== TEST 17:
--- pat: yz--ababyz
--- txt:
--- out: --
@@ -2111,6 +2111,10 @@ ngx_http_lua_socket_compile_pattern(u_char *data, size_t len,
cp->pattern.len = len;
+ if (len <= 2) {
+ return NGX_OK;
+ }
+
for (i = 1; i < len; i++) {
prefix_len = 1;

0 comments on commit e60a948

Please sign in to comment.