diff options
-rw-r--r-- | odb/statement-processing.cxx | 57 |
1 files changed, 34 insertions, 23 deletions
diff --git a/odb/statement-processing.cxx b/odb/statement-processing.cxx index ed5bad5..f17e9ca 100644 --- a/odb/statement-processing.cxx +++ b/odb/statement-processing.cxx @@ -480,31 +480,14 @@ namespace odb } } - // Trailer. - // - const char* trailer_begin (0); - size_t trailer_size (0); - if (e - p != 0) - { - trailer_begin = p; - trailer_size = e - p; - } - // Empty case. // if (empty) { - r.reserve (header_size + (trailer_size == 0 ? 0 : trailer_size + 1)); - r.assign (s, header_size); - - if (trailer_size != 0) - { - r += ' '; - r.append (trailer_begin, trailer_size); - } + r.clear (); #ifdef LIBODB_TRACE_STATEMENT_PROCESSING - if (r.size () != n) + if (n != 0) cerr << endl << "old: '" << s << "'" << endl << endl << "new: '" << r << "'" << endl << endl; @@ -513,6 +496,16 @@ namespace odb return; } + // Trailer. + // + const char* trailer_begin (0); + size_t trailer_size (0); + if (e - p != 0) + { + trailer_begin = p; + trailer_size = e - p; + } + // Assume the same size as the original. It can only shrink, and in // most cases only slightly. So this is a good approximation. // @@ -575,13 +568,32 @@ namespace odb #endif string& r) { - bool fast (true); // Fast case (if all present). - for (size_t i (0); i != bind_size && fast; ++i) + bool empty (true); // Empty case (if none present). + bool fast (true); // Fast case (if all present). + for (size_t i (0); i != bind_size && (empty || fast); ++i) { - if (bind_at (i, bind, bind_skip) == 0) + if (bind_at (i, bind, bind_skip) != 0) + empty = false; + else fast = false; } + // Empty. + // + if (empty) + { + r.clear (); + +#ifdef LIBODB_TRACE_STATEMENT_PROCESSING + if (*s != '\0') + cerr << endl + << "old: '" << s << "'" << endl << endl + << "new: '" << r << "'" << endl << endl; +#endif + + return; + } + // Fast path: just remove the "structure". // #ifndef LIBODB_DEBUG_STATEMENT_PROCESSING @@ -620,7 +632,6 @@ namespace odb if (p != e) p++; - // JOIN list. // const char* joins_begin (0), *joins_end (0); |