File tree Expand file tree Collapse file tree 3 files changed +7
-18
lines changed Expand file tree Collapse file tree 3 files changed +7
-18
lines changed Original file line number Diff line number Diff line change 11package lua
22
33import (
4- "reflect"
54 "unsafe"
65)
76
@@ -26,21 +25,18 @@ func init() {
2625
2726// allocator is a fast bulk memory allocator for the LValue.
2827type allocator struct {
29- size int
30- fptrs []float64
31- fheader * reflect.SliceHeader
28+ size int
29+ fptrs []float64
3230
3331 scratchValue LValue
3432 scratchValueP * iface
3533}
3634
3735func newAllocator (size int ) * allocator {
3836 al := & allocator {
39- size : size ,
40- fptrs : make ([]float64 , 0 , size ),
41- fheader : nil ,
37+ size : size ,
38+ fptrs : make ([]float64 , 0 , size ),
4239 }
43- al .fheader = (* reflect .SliceHeader )(unsafe .Pointer (& al .fptrs ))
4440 al .scratchValue = LNumber (0 )
4541 al .scratchValueP = (* iface )(unsafe .Pointer (& al .scratchValue ))
4642
@@ -63,7 +59,6 @@ func (al *allocator) LNumber2I(v LNumber) LValue {
6359 // check if we need a new alloc page
6460 if cap (al .fptrs ) == len (al .fptrs ) {
6561 al .fptrs = make ([]float64 , 0 , al .size )
66- al .fheader = (* reflect .SliceHeader )(unsafe .Pointer (& al .fptrs ))
6762 }
6863
6964 // alloc a new float, and store our value into it
Original file line number Diff line number Diff line change 11module github.com/yuin/gopher-lua
22
3- go 1.17
3+ go 1.20
44
55require github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e
66
Original file line number Diff line number Diff line change 44 "bufio"
55 "fmt"
66 "io"
7- "reflect"
87 "strconv"
98 "strings"
109 "time"
@@ -255,11 +254,6 @@ func strCmp(s1, s2 string) int {
255254 }
256255}
257256
258- func unsafeFastStringToReadOnlyBytes (s string ) (bs []byte ) {
259- sh := (* reflect .StringHeader )(unsafe .Pointer (& s ))
260- bh := (* reflect .SliceHeader )(unsafe .Pointer (& bs ))
261- bh .Data = sh .Data
262- bh .Cap = sh .Len
263- bh .Len = sh .Len
264- return
257+ func unsafeFastStringToReadOnlyBytes (s string ) []byte {
258+ return unsafe .Slice (unsafe .StringData (s ), len (s ))
265259}
You can’t perform that action at this time.
0 commit comments