diff options
author | drh <> | 2021-01-29 13:47:36 +0000 |
---|---|---|
committer | drh <> | 2021-01-29 13:47:36 +0000 |
commit | f54a80fe5c4afa61f17ec3380a4201b1fda630d7 (patch) | |
tree | 24e8b15380cd10017d8bd8e96989263bf0b65620 /src | |
parent | 16cd8b96d3e2cb80e169beee529307d0f0fdf51c (diff) | |
download | sqlite-f54a80fe5c4afa61f17ec3380a4201b1fda630d7.tar.gz sqlite-f54a80fe5c4afa61f17ec3380a4201b1fda630d7.zip |
Performance optimization (and size reduction) in sqlite3TriggerList() for the
common case where there are no TEMP triggers.
FossilOrigin-Name: 0defaf730bdc82212a5d3feeb2e16f16423b1691b0aaa7da1787eb82ea39ae9e
Diffstat (limited to 'src')
-rw-r--r-- | src/trigger.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/trigger.c b/src/trigger.c index 0c8cf5334..a9378fd3a 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -48,28 +48,32 @@ void sqlite3DeleteTriggerStep(sqlite3 *db, TriggerStep *pTriggerStep){ ** pTab as well as the triggers lised in pTab->pTrigger. */ Trigger *sqlite3TriggerList(Parse *pParse, Table *pTab){ - Schema * const pTmpSchema = pParse->db->aDb[1].pSchema; - Trigger *pList = 0; /* List of triggers to return */ + Schema *pTmpSchema; /* Schema of the pTab table */ + Trigger *pList; /* List of triggers to return */ + HashElem *p; /* Loop variable for TEMP triggers */ if( pParse->disableTriggers ){ return 0; } - + pTmpSchema = pParse->db->aDb[1].pSchema; + p = sqliteHashFirst(&pTmpSchema->trigHash); + if( p==0 ){ + return pTab->pTrigger; + } + pList = pTab->pTrigger; if( pTmpSchema!=pTab->pSchema ){ - HashElem *p; - assert( sqlite3SchemaMutexHeld(pParse->db, 0, pTmpSchema) ); - for(p=sqliteHashFirst(&pTmpSchema->trigHash); p; p=sqliteHashNext(p)){ + while( p ){ Trigger *pTrig = (Trigger *)sqliteHashData(p); if( pTrig->pTabSchema==pTab->pSchema && 0==sqlite3StrICmp(pTrig->table, pTab->zName) ){ - pTrig->pNext = (pList ? pList : pTab->pTrigger); + pTrig->pNext = pList; pList = pTrig; } + p = sqliteHashNext(p); } } - - return (pList ? pList : pTab->pTrigger); + return pList; } /* |