Skip to content

Commit 7548566

Browse files
committed
db.d: avoid some unnecessary work
1 parent ed06f90 commit 7548566

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/db.d

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ final class Database
11211121
bool del_user_tickers(RoomType type)(string username)
11221122
{
11231123
auto sql = text(
1124-
"WITH tickers_to_delete AS (",
1124+
"DELETE FROM ", tickers_table, " WHERE rowid IN (",
11251125
" SELECT t.rowid FROM ", tickers_table, " t",
11261126
" JOIN ", rooms_table, " r ON t.room = r.room",
11271127
" WHERE t.username = ?"
@@ -1132,10 +1132,7 @@ final class Database
11321132
sql ~= " AND r.type = ?";
11331133
parameters ~= [text(cast(int) type)];
11341134
}
1135-
sql ~= text(
1136-
") DELETE FROM ", tickers_table,
1137-
" WHERE rowid IN (SELECT rowid FROM tickers_to_delete);"
1138-
);
1135+
sql ~= ");";
11391136

11401137
query(sql, parameters);
11411138

@@ -1179,8 +1176,7 @@ final class Database
11791176
Appender!(RoomTicker[]) tickers;
11801177
enum sql = text(
11811178
"SELECT username, content FROM ", tickers_table,
1182-
" WHERE room = ?",
1183-
" ORDER BY rowid;"
1179+
" WHERE room = ?"
11841180
);
11851181

11861182
const res = query(sql, [room_name]);
@@ -1205,7 +1201,7 @@ final class Database
12051201
sql ~= " AND r.type = ?";
12061202
parameters ~= [text(cast(int) type)];
12071203
}
1208-
sql ~= " ORDER BY t.rowid;";
1204+
sql ~= ";";
12091205

12101206
const res = query(sql, parameters);
12111207
foreach (ref record ; res) {

0 commit comments

Comments
 (0)