Philio / GoMySQL

The most complete and stable MySQL client library written completely in Go. For discussion, ideas, suggestions, feature requests etc, please visit the GoMySQL Google Group (link below). For any issues/bugs or need some help, please post an issue on Github.
https://groups.google.com/group/gomysql
Other
189 stars 37 forks source link

Considerably faster MySQL.Escape() #28

Closed ghost closed 13 years ago

ghost commented 13 years ago

Strings are immutable in Go. When building a string in a loop, avoid += and use a byte buffer instead. Comparative tests on my machine show a 7x speed increase.

ghost commented 13 years ago

It seems Git decided to list the Example fixes as well. I rewrote the examples to use the updated method signatures. Added usage of the defer statement to ensure the database and Statements are properly closed upon exit of the app. I removed the hard coded user credentials from the examples and replaced them with command line arguments by using the flag package.

Added a makefile to the Examples dir to allow building of examples with 1 make command.