Permalink
Browse files

some additional comments

  • Loading branch information...
1 parent 84ca7ac commit f3a01069f5b6e0165d36c500f894edbffb213cad @rfk committed Apr 3, 2011
Showing with 6 additions and 1 deletion.
  1. +4 −1 tnetstring/tns_core.c
  2. +2 −0 tnetstring/tns_outbuf_back.c
View
@@ -35,10 +35,13 @@ static size_t tns_strtosz(const char *data, size_t len, size_t *sz, char **end);
#include "tns_outbuf_back.c"
+// This appears to be faster than using strncmp to compare
+// against a small string constant.
#define STR_EQ_TRUE(s) (s[0]=='t' && s[1]=='r' && s[2]=='u' && s[3]=='e')
#define STR_EQ_FALSE(s) (s[0]=='f' && s[1]=='a' && s[2]=='l' \
&& s[3]=='s' && s[4] == 'e')
+
static void* tns_parse(const char *data, size_t len, char **remain)
{
char *valstr = NULL;
@@ -282,7 +285,7 @@ tns_strtosz(const char *data, size_t len, size_t *sz, char **end)
pos++;
// The netstring spec explicitly forbits padding zeros.
- // If it's a zero, we must be at end.
+ // If it's a zero, it must be the only char in the string.
if(value == 0) {
*sz = value;
*end = (char*) pos;
@@ -8,6 +8,8 @@
// The advantage of this scheme is that the data is the right way round,
// so you can shuffle it about using memmove. The disadvantage is that
// reallocating the buffer is tricker as you must move the data by hand.
+// On my machines, the ability to use memmove seems to be a very slight
+// win over tns_outbuf_rev.c.
//
struct tns_outbuf_s {

0 comments on commit f3a0106

Please sign in to comment.