Skip to content
Browse files

go: SHORT_BINARY -> []byte

These used to be strings, but this messed with the uft8 flags.  Update
the regexp compat layer to be []byte too.
  • Loading branch information...
1 parent 5cde00b commit e2dae5780444e08cb557e2ed0f47340af3f46d4d @dgryski dgryski committed Mar 23, 2013
Showing with 6 additions and 7 deletions.
  1. +4 −5 Go/sereal/decode.go
  2. +2 −2 Go/sereal/perl.go
View
9 Go/sereal/decode.go
@@ -364,10 +364,9 @@ func decode(b []byte, idx int, tracked map[int]reflect.Value) (reflect.Value, in
ln := int(tag & 0x1F) // get length from tag
idx++
- // assume these are strings
-
- ptr = reflect.New(reflect.TypeOf(""))
- ptr.Elem().SetString(string(b[idx : idx+ln]))
+ a := make([]byte, ln)
+ copy(a, b[idx:idx+ln])
+ ptr = reflect.ValueOf(&a)
idx += ln
@@ -404,7 +403,7 @@ func decode(b []byte, idx int, tracked map[int]reflect.Value) (reflect.Value, in
modifiers, sz, _ := decode(b, idx, tracked)
idx += sz
- re := &PerlRegexp{pattern.Elem().String(), modifiers.Elem().String()}
+ re := &PerlRegexp{pattern.Elem().Bytes(), modifiers.Elem().Bytes()}
ptr = reflect.ValueOf(re)
View
4 Go/sereal/perl.go
@@ -18,6 +18,6 @@ type PerlWeakRef struct {
type PerlUndef struct{}
type PerlRegexp struct {
- Pattern string
- Modifiers string
+ Pattern []byte
+ Modifiers []byte
}

0 comments on commit e2dae57

Please sign in to comment.
Something went wrong with that request. Please try again.