spacemonkeygo / openssl

OpenSSL bindings for Go
http://godoc.org/github.com/spacemonkeygo/openssl
Apache License 2.0
474 stars 237 forks source link

Avoid cgoPointerCheck in Write(). #55

Closed hughe closed 7 years ago

hughe commented 8 years ago

In benchmarks cgoPointerCheck was taking about the same time as cgocall EVP_DigestUpdate and making SHA256Hash run about 30% slower than the Go stdlib implementation of SHA256 in Go 1.6. With this change it runs about 60% faster.

hughe commented 8 years ago

I just updated this PR to include 5538ac1 which allows it to compile on Linux (Centos 7) as well as my Mac.

zeebo commented 7 years ago

Unfortunately, Go needs to know all of the pointers that have been passed to C land so that it can keep them alive. Casting them to a uintptr makes them invisible to the GC, making this unsafe to do.