classification
Title: Unnecessary variable assignment and initial loop check in pysqlite_cursor_executescript
Type: performance Stage: patch review
Components: Library (Lib) Versions: Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: alex.henrie, ghaering
Priority: normal Keywords: patch

Created on 2020-02-02 02:05 by alex.henrie, last changed 2020-02-09 20:14 by terry.reedy.

Pull Requests
URL Status Linked Edit
PR 18305 open alex.henrie, 2020-02-02 02:06
Messages (1)
msg361200 - (view) Author: Alex Henrie (alex.henrie) * Date: 2020-02-02 02:05
pysqlite_cursor_executescript currently has the following while loop:

    /* execute statement, and ignore results of SELECT statements */
    rc = SQLITE_ROW;
    while (rc == SQLITE_ROW) {
        rc = pysqlite_step(statement, self->connection);
        if (PyErr_Occurred()) {
            (void)sqlite3_finalize(statement);
            goto error;
        }
    }

This can and should be rewritten as a do-while loop to avoid having to initialize rc to SQLITE_ROW and then check its value knowing that the value check will succeed.
History
Date User Action Args
2020-02-09 20:14:08terry.reedysetnosy: + ghaering
2020-02-02 02:06:58alex.henriesetkeywords: + patch
stage: patch review
pull_requests: + pull_request17682
2020-02-02 02:05:21alex.henriecreate