From 654e686079a88b0dcde31db4adbd0a8d5fd67575 Mon Sep 17 00:00:00 2001 From: Syoyo Fujita Date: Sat, 14 May 2016 17:25:36 +0900 Subject: [PATCH] Optimized a bit. --- experimental/optimized-parse.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/experimental/optimized-parse.cc b/experimental/optimized-parse.cc index 372ccd8..bfbe9e7 100644 --- a/experimental/optimized-parse.cc +++ b/experimental/optimized-parse.cc @@ -271,7 +271,7 @@ static inline int my_atoi( const char *c ) { if( *c == '-' ) sign = -1; c++; } - while ( isdigit( *c ) ) { + while ( ((*c) >= '0') && ((*c) <= '9') ) { // isdigit(*c) value *= 10; value += (int) (*c-'0'); c++; @@ -596,12 +596,14 @@ typedef struct bool parseLine(Command *command, const char *p, size_t p_len) { - StackVector linebuf; - linebuf->resize(p_len + 1); - memcpy(&linebuf->at(0), p, p_len); + char linebuf[4096]; + assert(p_len < 4095); + //StackVector linebuf; + //linebuf->resize(p_len + 1); + memcpy(&linebuf, p, p_len); linebuf[p_len] = '\0'; - const char *token = &linebuf->at(0); + const char *token = linebuf; command->type = COMMAND_EMPTY;