Fossil SCM

Minor performance improvement in sync_log_entry().

drh 2021-12-19 20:14 synclog
Commit c0fd8338f616a72afc961fab54e3fe7a937db8f14d489e4fe91c42f383b120e4
1 file changed +16 -12
+16 -12
--- src/sync.c
+++ src/sync.c
@@ -111,27 +111,31 @@
111111
void sync_log_entry(
112112
int syncFlags, /* Indicates whether a PUSH or PULL or both */
113113
const char *zRemote, /* Server with which we push or pull */
114114
const char *zType /* Type of sync. NULL for normal */
115115
){
116
+ Stmt s;
117
+ db_prepare(&s,
118
+ "INSERT INTO repository.synclog(sfrom,sto,stime,stype)"
119
+ " VALUES(:sfrom,:sto,julianday(),:stype)"
120
+ " ON CONFLICT DO UPDATE SET stime=julianday()"
121
+ );
116122
schema_synclog();
117123
if( syncFlags & (SYNC_PULL|SYNC_CLONE) ){
118
- db_multi_exec(
119
- "INSERT INTO repository.synclog(sfrom,sto,stime,stype)"
120
- " VALUES(%Q,'this',julianday(),%Q)"
121
- " ON CONFLICT DO UPDATE SET stime=julianday()",
122
- zRemote, zType
123
- );
124
+ db_bind_text(&s, ":sfrom", zRemote);
125
+ db_bind_text(&s, ":sto", "this");
126
+ db_bind_text(&s, ":stype", zType);
127
+ db_step(&s);
128
+ db_reset(&s);
124129
}
125130
if( syncFlags & (SYNC_PUSH) ){
126
- db_multi_exec(
127
- "INSERT INTO repository.synclog(sfrom,sto,stime,stype)"
128
- " VALUES('this',%Q,julianday(),%Q)"
129
- " ON CONFLICT DO UPDATE SET stime=julianday()",
130
- zRemote, zType
131
- );
131
+ db_bind_text(&s, ":sfrom", "this");
132
+ db_bind_text(&s, ":sto", zRemote);
133
+ db_bind_text(&s, ":stype", zType);
134
+ db_step(&s);
132135
}
136
+ db_finalize(&s);
133137
}
134138
135139
136140
/*
137141
** If the repository is configured for autosyncing, then do an
138142
--- src/sync.c
+++ src/sync.c
@@ -111,27 +111,31 @@
111 void sync_log_entry(
112 int syncFlags, /* Indicates whether a PUSH or PULL or both */
113 const char *zRemote, /* Server with which we push or pull */
114 const char *zType /* Type of sync. NULL for normal */
115 ){
 
 
 
 
 
 
116 schema_synclog();
117 if( syncFlags & (SYNC_PULL|SYNC_CLONE) ){
118 db_multi_exec(
119 "INSERT INTO repository.synclog(sfrom,sto,stime,stype)"
120 " VALUES(%Q,'this',julianday(),%Q)"
121 " ON CONFLICT DO UPDATE SET stime=julianday()",
122 zRemote, zType
123 );
124 }
125 if( syncFlags & (SYNC_PUSH) ){
126 db_multi_exec(
127 "INSERT INTO repository.synclog(sfrom,sto,stime,stype)"
128 " VALUES('this',%Q,julianday(),%Q)"
129 " ON CONFLICT DO UPDATE SET stime=julianday()",
130 zRemote, zType
131 );
132 }
 
133 }
134
135
136 /*
137 ** If the repository is configured for autosyncing, then do an
138
--- src/sync.c
+++ src/sync.c
@@ -111,27 +111,31 @@
111 void sync_log_entry(
112 int syncFlags, /* Indicates whether a PUSH or PULL or both */
113 const char *zRemote, /* Server with which we push or pull */
114 const char *zType /* Type of sync. NULL for normal */
115 ){
116 Stmt s;
117 db_prepare(&s,
118 "INSERT INTO repository.synclog(sfrom,sto,stime,stype)"
119 " VALUES(:sfrom,:sto,julianday(),:stype)"
120 " ON CONFLICT DO UPDATE SET stime=julianday()"
121 );
122 schema_synclog();
123 if( syncFlags & (SYNC_PULL|SYNC_CLONE) ){
124 db_bind_text(&s, ":sfrom", zRemote);
125 db_bind_text(&s, ":sto", "this");
126 db_bind_text(&s, ":stype", zType);
127 db_step(&s);
128 db_reset(&s);
 
129 }
130 if( syncFlags & (SYNC_PUSH) ){
131 db_bind_text(&s, ":sfrom", "this");
132 db_bind_text(&s, ":sto", zRemote);
133 db_bind_text(&s, ":stype", zType);
134 db_step(&s);
 
 
135 }
136 db_finalize(&s);
137 }
138
139
140 /*
141 ** If the repository is configured for autosyncing, then do an
142

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button