From: drh Date: Wed, 4 Jan 2017 04:18:00 +0000 (+0000) Subject: Factor constant functions out of the inner loop since they are more expensive X-Git-Tag: version-3.17.0~138 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=49c5ab243b21be7afcbd55821505e6328de48cda;p=thirdparty%2Fsqlite.git Factor constant functions out of the inner loop since they are more expensive than the extra OP_Copy needed to move the result into place. FossilOrigin-Name: 80ad317f89c46db0d0d252aefdc036a34a61183d --- 49c5ab243b21be7afcbd55821505e6328de48cda diff --cc manifest index c7180b2831,57528b4fdd..868d5454ad --- a/manifest +++ b/manifest @@@ -1,5 -1,5 +1,5 @@@ - C Use\scompiler\sintrinsic\sfunctions\sfor\ssigned\sinteger\smath\swhen\soverflow\ndetection\sis\sneeded. - D 2017-01-03T21:57:11.355 -C Clean\sup\sthe\simplementation\sof\sconstant\sfunction\sfactorization. -D 2017-01-04T04:10:02.788 ++C Factor\sconstant\sfunctions\sout\sof\sthe\sinner\sloop\ssince\sthey\sare\smore\sexpensive\nthan\sthe\sextra\sOP_Copy\sneeded\sto\smove\sthe\sresult\sinto\splace. ++D 2017-01-04T04:18:00.128 F Makefile.in 41bd4cad981487345c4a84081074bcdb876e4b2e F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@@ -341,7 -341,7 +341,7 @@@ F src/ctime.c 9f2296a4e5d26ebf0e0d95a0a F src/date.c dc3f1391d9297f8c748132813aaffcb117090d6e F src/dbstat.c 19ee7a4e89979d4df8e44cfac7a8f905ec89b77d F src/delete.c c8bc10d145c9666a34ae906250326fdaa8d58fa5 - F src/expr.c 449cbb8b9857ff8eb685b72555086818a178858c -F src/expr.c 9e60a71c788a00328652ed37b9f6b6b4374592a3 ++F src/expr.c f06f41e5e5daca10fb090e70a2502dcc0dbc992b F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 2e9aabe1aee76273aff8a84ee92c464e095400ae F src/func.c c67273e1ec08abbdcc14c189892a3ff6eeece86b @@@ -1541,8 -1541,7 +1541,8 @@@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a9 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 - P bed0eaa5f50112e64fc97a2afdc9d56cf8f5026a 4c2efd4239bf07eb4b92d4af54edd68ee6312670 - R 4be5114c40ec1b8757eebb3b6a7e4284 - T +closed 4c2efd4239bf07eb4b92d4af54edd68ee6312670 -P 62e9270a8057d758621da33adb27fad14225f95d -R 1aa2a1487ef2ae3f764297787590ccdb ++P d3ac32a6e7f1823450feb3d1089802542090d164 2ab997e47998d261bd6190bbce5c09f3fbd4cfd3 ++R 2d314fb6a2447c90f8995bffa1ef5d9e ++T +closed 2ab997e47998d261bd6190bbce5c09f3fbd4cfd3 U drh - Z 6bd6e679c9840443d9b2f38c8bc4573f -Z 020211a07112e857de5c9ad202e08252 ++Z 2f6b9afef8397c67d3717af984641685 diff --cc manifest.uuid index 42e6e71ba8,aabd0aa958..38b15c0900 --- a/manifest.uuid +++ b/manifest.uuid @@@ -1,1 -1,1 +1,1 @@@ - d3ac32a6e7f1823450feb3d1089802542090d164 -2ab997e47998d261bd6190bbce5c09f3fbd4cfd3 ++80ad317f89c46db0d0d252aefdc036a34a61183d diff --cc src/expr.c index 3bb0ca03f1,d6133c0d74..154d078ff7 --- a/src/expr.c +++ b/src/expr.c @@@ -3612,6 -3612,11 +3612,11 @@@ int sqlite3ExprCodeTarget(Parse *pParse u8 enc = ENC(db); /* The text encoding used by this database */ CollSeq *pColl = 0; /* A collating sequence */ + if( ConstFactorOk(pParse) && sqlite3ExprIsConstantNotJoin(pExpr) ){ - /* SQL function can be expensive. So try to move constant functions ++ /* SQL functions can be expensive. So try to move constant functions + ** out of the inner loop, even if that means an extra OP_Copy. */ + return sqlite3ExprCodeAtInit(pParse, pExpr, -1); + } assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); if( ExprHasProperty(pExpr, EP_TokenOnly) ){ pFarg = 0;