File tree Expand file tree Collapse file tree 3 files changed +7
-21
lines changed Expand file tree Collapse file tree 3 files changed +7
-21
lines changed Original file line number Diff line number Diff line change 11package lua
22
33import (
4- "reflect"
54 "unsafe"
65)
76
@@ -13,9 +12,6 @@ type iface struct {
1312
1413const preloadLimit LNumber = 128
1514
16- var _fv float64
17- var _uv uintptr
18-
1915var preloads [int (preloadLimit )]LValue
2016
2117func init () {
@@ -26,21 +22,18 @@ func init() {
2622
2723// allocator is a fast bulk memory allocator for the LValue.
2824type allocator struct {
29- size int
30- fptrs []float64
31- fheader * reflect.SliceHeader
25+ size int
26+ fptrs []float64
3227
3328 scratchValue LValue
3429 scratchValueP * iface
3530}
3631
3732func newAllocator (size int ) * allocator {
3833 al := & allocator {
39- size : size ,
40- fptrs : make ([]float64 , 0 , size ),
41- fheader : nil ,
34+ size : size ,
35+ fptrs : make ([]float64 , 0 , size ),
4236 }
43- al .fheader = (* reflect .SliceHeader )(unsafe .Pointer (& al .fptrs ))
4437 al .scratchValue = LNumber (0 )
4538 al .scratchValueP = (* iface )(unsafe .Pointer (& al .scratchValue ))
4639
@@ -63,7 +56,6 @@ func (al *allocator) LNumber2I(v LNumber) LValue {
6356 // check if we need a new alloc page
6457 if cap (al .fptrs ) == len (al .fptrs ) {
6558 al .fptrs = make ([]float64 , 0 , al .size )
66- al .fheader = (* reflect .SliceHeader )(unsafe .Pointer (& al .fptrs ))
6759 }
6860
6961 // 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