Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove sqlc queries internalized on driver/executor structs (#455)
A small refactor to remove the embedded sqlc queries that's internalized on the structs for the drivers and executors. I originally did this because I thought it was a small memory optimization, but it turns out that it doesn't matter because `Queries` is an empty struct. It uses zero bytes of memory, and multiple sequential initializations end up pointing to the same memory location. Here's a test script to prove that this is true: package main import ( "fmt" "unsafe" "github.com/riverqueue/river/riverdriver/riverpgxv5/internal/dbsqlc" ) func main() { var ( a = dbsqlc.New() b = dbsqlc.New() ) fmt.Printf("size of a = %v\n", unsafe.Sizeof(*a)) fmt.Printf("addr of a = %p\n", a) fmt.Printf("size of b = %v\n", unsafe.Sizeof(*b)) fmt.Printf("addr of b = %p\n", b) anotherFunction() } // Even in a different function, the same struct is reused func anotherFunction() { c := dbsqlc.New() fmt.Printf("size of c = %v\n", unsafe.Sizeof(*c)) fmt.Printf("addr of c = %p\n", c) } Run output: size of a = 0 addr of a = 0x1031710c0 size of b = 0 addr of b = 0x1031710c0 size of c = 0 addr of c = 0x1031710c0
- Loading branch information