boris
Advanced tools
Comparing version 0.12.5 to 0.12.6
@@ -10,3 +10,3 @@ /* | ||
// match CRLF value | ||
, crlf = new Buffer( '\r\n' ).readUInt16BE() | ||
, crlf = new Buffer( '\r\n' ).readUInt16BE( 0 ) | ||
, Rule = function ( char ) { | ||
@@ -35,18 +35,10 @@ var me = this | ||
// match CRLF | ||
rproto.match = function ( buff, spos ) { | ||
rproto.match = function ( buff, offset ) { | ||
var b = buff | ||
, len = Math.max( 0, b.length - 1 ) | ||
, i = spos || 0 | ||
, blen = b.length | ||
, l = blen ? blen - 1 : 0 | ||
, o = offset || 0 | ||
; | ||
/* | ||
* Complexity is O(K) for any K-length input | ||
* it is the best method when input is dense of crlf | ||
* sequences; for sparse inputs it could be switched | ||
* to an algorithm like quicksearch; in this way, | ||
* it could gain a ~2x boost in matching performance. | ||
*/ | ||
for ( ; i < len; ++i ) | ||
if ( ( b[ i ] === 0x0d ) && ( b[ i + 1 ] === 0x0a ) ) | ||
return i; | ||
for ( ; o < l; ++o ) | ||
if ( ! ( crlf ^ ( b[ o ] << 8 | b[ o + 1 ] ) ) ) return o; | ||
return -1; | ||
@@ -53,0 +45,0 @@ }; |
{ | ||
"name": "boris" | ||
, "version": "0.12.5" | ||
, "version": "0.12.6" | ||
, "description": "Boris a pure javascript parser for the Redis serialization protocol (RESP)." | ||
@@ -5,0 +5,0 @@ , "homepage": "https://github.com/rootslab/boris" |
42711
724