From 591909c344eecf314505b31af0fb32ca068248f7 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 25 Jun 2015 23:52:48 +0000 Subject: [PATCH] Optimization to sqlite3_value_bytes() for the common case that does not require a data transformation. FossilOrigin-Name: 8d79f3a1443391bee204bb8c49240f44477168db --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbemem.c | 17 +++++++++++++---- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index f42ebf288a..785ef7153f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplifications\sand\sperformance\simprovements\sin\sinsertCell(). -D 2015-06-25T19:53:48.178 +C Optimization\sto\ssqlite3_value_bytes()\sfor\sthe\scommon\scase\sthat\sdoes\snot\nrequire\sa\sdata\stransformation. +D 2015-06-25T23:52:48.104 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 1063c58075b7400d93326b0eb332b48a54f53025 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -319,7 +319,7 @@ F src/vdbeInt.h 20295e482121d13437f69985f77db211cdc8bac1 F src/vdbeapi.c 6a0d7757987018ff6b1b81bc5293219cd26bb299 F src/vdbeaux.c 4c82d6f686f72ea7d266d26d528a171b728626f7 F src/vdbeblob.c 4f2e8e075d238392df98c5e03a64342465b03f90 -F src/vdbemem.c 4e947cd322bb531e3f7f6f58f0f536d182b38ef8 +F src/vdbemem.c ae38a0d35ae71cf604381a887c170466ba518090 F src/vdbesort.c f5009e7a35e3065635d8918b9a31f498a499976b F src/vdbetrace.c 8befe829faff6d9e6f6e4dee5a7d3f85cc85f1a0 F src/vtab.c c535e80259ebe616467181a83a4263555b97c694 @@ -1286,7 +1286,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 78da0f69cb3289e332018864004f319f2764a5c8 -R 0d165d2d8c01ecd2475fdbe233dfe5e0 +P 7d02e6c992ef92e1f77ebc13889e17c028454b06 +R 055499679190be686aed6dd5c50e96a1 U drh -Z 8a4a8bb2d9c667bdbc4293aaa6065234 +Z a43ea71012a447eaba4e577595223851 diff --git a/manifest.uuid b/manifest.uuid index e18ea8d4d0..d16841f228 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7d02e6c992ef92e1f77ebc13889e17c028454b06 \ No newline at end of file +8d79f3a1443391bee204bb8c49240f44477168db \ No newline at end of file diff --git a/src/vdbemem.c b/src/vdbemem.c index 1076812609..648a53d2a3 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -1694,17 +1694,26 @@ void sqlite3ValueFree(sqlite3_value *v){ } /* -** Return the number of bytes in the sqlite3_value object assuming -** that it uses the encoding "enc" +** The sqlite3ValueBytes() routine returns the number of bytes in the +** sqlite3_value object assuming that it uses the encoding "enc". +** The valueBytes() routine is a helper function. */ +static SQLITE_NOINLINE int valueBytes(sqlite3_value *pVal, u8 enc){ + return valueToText(pVal, enc)!=0 ? pVal->n : 0; +} int sqlite3ValueBytes(sqlite3_value *pVal, u8 enc){ Mem *p = (Mem*)pVal; - if( (p->flags & MEM_Blob)!=0 || sqlite3ValueText(pVal, enc) ){ + assert( (p->flags & MEM_Null)==0 || (p->flags & (MEM_Str|MEM_Blob))==0 ); + if( (p->flags & MEM_Str)!=0 && pVal->enc==enc ){ + return p->n; + } + if( (p->flags & MEM_Blob)!=0 ){ if( p->flags & MEM_Zero ){ return p->n + p->u.nZero; }else{ return p->n; } } - return 0; + if( p->flags & MEM_Null ) return 0; + return valueBytes(pVal, enc); }