Skip to content

Instantly share code, notes, and snippets.

@berfarah
Created October 1, 2018 21:27
Show Gist options
  • Save berfarah/3054ea45162e0c6f51c6abfdb522b1f2 to your computer and use it in GitHub Desktop.
Save berfarah/3054ea45162e0c6f51c6abfdb522b1f2 to your computer and use it in GitHub Desktop.
Iterative Optimization on Hot Paths: Optimization 1: Pass by value
// Valuer creates a sql/driver.Valuer from the type and value.
-func (d Descriptor) Valuer(val reflect.Value) Valuer {
+func (d *Descriptor) Valuer(val reflect.Value) Valuer {
- return Valuer{Descriptor: &d, value: val}
+ return Valuer{Descriptor: d, value: val}
}
// Scanner creates a sql.Scanner from the descriptor.
-func (d Descriptor) Scanner() *Scanner { return &Scanner{Descriptor: &d} }
+func (d *Descriptor) Scanner() *Scanner { return &Scanner{Descriptor: d} }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment