Perfect-SQLite icon indicating copy to clipboard operation
Perfect-SQLite copied to clipboard

Making closure parameters non-escaping where possible (forEachRow etc)

Open zmeyc opened this issue 9 years ago • 1 comments

Please consider marking closures in methods such as forEachRow non escaping (@noescape attribute). They aren't capturing the closure anyway, but if this attribute is absent, closure requires prefixing member references with explicit 'self.'

            try DB.connection.forEachRow(statement: "SELECT * FROM topics_files WHERE user_id = ?", doBindings: { statement in
                try statement.bind(position: 0, self.userId!) // <---- self.
            }) { statement, row in
                self.topicsData = statement.columnBlob(position: 0) // <---- self.
            }
    public func forEachRow(statement: String, doBindings: @noescape (SQLiteStmt) throws -> (), handleRow: @noescape (SQLiteStmt, Int) -> ()) throws {}
...
    func forEachRowBody(stat: SQLiteStmt, handleRow: @noescape (SQLiteStmt, Int) -> ()) throws {}
...
etc

zmeyc avatar Jun 27 '16 20:06 zmeyc

Good call. Feel free to submit a PR :)

iamjono avatar Jul 03 '16 00:07 iamjono