From 99819c4bbb0c19782cf595b3c4bd3629fa6daa1e Mon Sep 17 00:00:00 2001 From: c9s Date: Tue, 20 May 2014 23:25:12 +0800 Subject: [PATCH] move strndiff and strdiff to node.c and make it private --- include/r3_str.h | 4 ---- src/node.c | 21 ++++++++++++++++++++- src/str.c | 20 -------------------- tests/bench_str.csv | 1 + 4 files changed, 21 insertions(+), 25 deletions(-) diff --git a/include/r3_str.h b/include/r3_str.h index 454ae8e..8da66fa 100644 --- a/include/r3_str.h +++ b/include/r3_str.h @@ -10,10 +10,6 @@ #include "r3_define.h" #include "config.h" -int strndiff(char * d1, char * d2, unsigned int n); - -int strdiff(char * d1, char * d2); - int slug_count(char * p, int len); char * compile_slug(char * str, int len); diff --git a/src/node.c b/src/node.c index c592021..e278e1f 100644 --- a/src/node.c +++ b/src/node.c @@ -18,9 +18,28 @@ #include "r3.h" #include "str_array.h" - // String value as the index http://judy.sourceforge.net/doc/JudySL_3x.htm + +static int strndiff(char * d1, char * d2, unsigned int n) { + char * o = d1; + while ( *d1 == *d2 && n-- > 0 ) { + d1++; + d2++; + } + return d1 - o; +} + +static int strdiff(char * d1, char * d2) { + char * o = d1; + while( *d1 == *d2 ) { + d1++; + d2++; + } + return d1 - o; +} + + /** * Create a node object */ diff --git a/src/str.c b/src/str.c index 124e1d2..814a012 100644 --- a/src/str.c +++ b/src/str.c @@ -12,26 +12,6 @@ #include "str_array.h" #include "r3_define.h" -int strndiff(char * d1, char * d2, unsigned int n) { - char * o = d1; - while ( *d1 == *d2 && n-- > 0 ) { - d1++; - d2++; - } - return d1 - o; -} - - -int strdiff(char * d1, char * d2) { - char * o = d1; - while( *d1 == *d2 ) { - d1++; - d2++; - } - return d1 - o; -} - - /** * provide a quick way to count slugs, simply search for '{' */ diff --git a/tests/bench_str.csv b/tests/bench_str.csv index ab5cfe9..f06c833 100644 --- a/tests/bench_str.csv +++ b/tests/bench_str.csv @@ -384,3 +384,4 @@ 1400593197,13978543.79 1400593210,13568445.16 1400593219,13704926.07 +1400599508,13991454.07