File tree 3 files changed +7
-21
lines changed
3 files changed +7
-21
lines changed Original file line number Diff line number Diff line change 1
1
package lua
2
2
3
3
import (
4
- "reflect"
5
4
"unsafe"
6
5
)
7
6
@@ -13,9 +12,6 @@ type iface struct {
13
12
14
13
const preloadLimit LNumber = 128
15
14
16
- var _fv float64
17
- var _uv uintptr
18
-
19
15
var preloads [int (preloadLimit )]LValue
20
16
21
17
func init () {
@@ -26,21 +22,18 @@ func init() {
26
22
27
23
// allocator is a fast bulk memory allocator for the LValue.
28
24
type allocator struct {
29
- size int
30
- fptrs []float64
31
- fheader * reflect.SliceHeader
25
+ size int
26
+ fptrs []float64
32
27
33
28
scratchValue LValue
34
29
scratchValueP * iface
35
30
}
36
31
37
32
func newAllocator (size int ) * allocator {
38
33
al := & allocator {
39
- size : size ,
40
- fptrs : make ([]float64 , 0 , size ),
41
- fheader : nil ,
34
+ size : size ,
35
+ fptrs : make ([]float64 , 0 , size ),
42
36
}
43
- al .fheader = (* reflect .SliceHeader )(unsafe .Pointer (& al .fptrs ))
44
37
al .scratchValue = LNumber (0 )
45
38
al .scratchValueP = (* iface )(unsafe .Pointer (& al .scratchValue ))
46
39
@@ -63,7 +56,6 @@ func (al *allocator) LNumber2I(v LNumber) LValue {
63
56
// check if we need a new alloc page
64
57
if cap (al .fptrs ) == len (al .fptrs ) {
65
58
al .fptrs = make ([]float64 , 0 , al .size )
66
- al .fheader = (* reflect .SliceHeader )(unsafe .Pointer (& al .fptrs ))
67
59
}
68
60
69
61
// alloc a new float, and store our value into it
Original file line number Diff line number Diff line change 1
1
module github.com/yuin/gopher-lua
2
2
3
- go 1.17
3
+ go 1.20
4
4
5
5
require github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e
6
6
Original file line number Diff line number Diff line change 4
4
"bufio"
5
5
"fmt"
6
6
"io"
7
- "reflect"
8
7
"strconv"
9
8
"strings"
10
9
"time"
@@ -255,11 +254,6 @@ func strCmp(s1, s2 string) int {
255
254
}
256
255
}
257
256
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 ))
265
259
}
You can’t perform that action at this time.
0 commit comments