summaryrefslogtreecommitdiff
path: root/pkg/payload
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-02-05 23:10:50 +0300
committerValery Piashchynski <[email protected]>2021-02-05 23:10:50 +0300
commit11b357c4457dfcbc1ef79478c200b794b5486b13 (patch)
tree29b512baf4d6a8ef79e19a0de3a9e642871b6d4e /pkg/payload
parent6c8cf12de734f01a0f0cdc4d2b55973cc8d1ddf1 (diff)
Faster toString convertation (only for the english)
Diffstat (limited to 'pkg/payload')
-rwxr-xr-xpkg/payload/payload.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/pkg/payload/payload.go b/pkg/payload/payload.go
index fac36852..bebe8df1 100755
--- a/pkg/payload/payload.go
+++ b/pkg/payload/payload.go
@@ -1,5 +1,7 @@
package payload
+import "unsafe"
+
// Payload carries binary header and body to stack and
// back to the server.
type Payload struct {
@@ -12,5 +14,10 @@ type Payload struct {
// String returns payload body as string
func (p *Payload) String() string {
- return string(p.Body)
+ return toString(p.Body)
}
+
+// unsafe, but lightning fast []byte to string conversion
+func toString(data []byte) string {
+ return *(*string)(unsafe.Pointer(&data))
+} \ No newline at end of file