-
Notifications
You must be signed in to change notification settings - Fork 601
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use safer bytesToString on appengine (#98)
- Loading branch information
1 parent
286b14e
commit 0bde97d
Showing
3 changed files
with
21 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// +build !appengine | ||
|
||
package bigcache | ||
|
||
import ( | ||
"reflect" | ||
"unsafe" | ||
) | ||
|
||
func bytesToString(b []byte) string { | ||
bytesHeader := (*reflect.SliceHeader)(unsafe.Pointer(&b)) | ||
strHeader := reflect.StringHeader{Data: bytesHeader.Data, Len: bytesHeader.Len} | ||
return *(*string)(unsafe.Pointer(&strHeader)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// +build appengine | ||
|
||
package bigcache | ||
|
||
func bytesToString(b []byte) string { | ||
return string(b) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters