Skip to content

Instantly share code, notes, and snippets.

@berfarah
Created October 1, 2018 21:36
Show Gist options
  • Save berfarah/4b9407d46654c3427c106e7f6b5df479 to your computer and use it in GitHub Desktop.
Save berfarah/4b9407d46654c3427c106e7f6b5df479 to your computer and use it in GitHub Desktop.
Iterative Optimization on Hot Paths: Optimization 4: Preventing escape of complex data types
func makeWhere(table *Table, filter Filter) (*SimpleWhere, error) {
for name, value := range filter {
// ...
- l = append(l, whereElem{column: column, value: column.Descriptor.Valuer(reflect.ValueOf(value))})
+ v, err := column.Descriptor.Valuer(reflect.ValueOf(value)).Value()
+ if err != nil {
+ return nil, err
+ }
+ l = append(l, whereElem{column: column, value: v})
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment