Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove unused code #683

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: remove unused code
  • Loading branch information
liuq19 committed Aug 6, 2024
commit 167aff2b81b8f121644fa44f08c88ca78ece5e29
1 change: 0 additions & 1 deletion go1.23
Submodule go1.23 deleted from c9940f
161 changes: 0 additions & 161 deletions internal/decoder/api/error_test.go

This file was deleted.

15 changes: 0 additions & 15 deletions internal/decoder/api/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,25 +67,16 @@ func NewStreamDecoder(r io.Reader) *StreamDecoder {
func (self *StreamDecoder) Decode(val interface{}) (err error) {
// read more data into buf
if self.More() {
// println(string(self.buf))
var s = self.scanp
try_skip:
var e = len(self.buf)
// println("s:", s, "e:", e, "scanned:",self.scanned, "scanp:",self.scanp, self.buf)
var src = rt.Mem2Str(self.buf[s:e])
// if len(src) > 5 {
// println(src[:5], src[len(src)-5:])
// } else {
// println(src)
// }
// try skip
var x = 0;
if y := native.SkipOneFast(&src, &x); y < 0 {
if self.readMore() {
// println("more")
goto try_skip
} else {
// println("no more")
err = SyntaxError{e, self.s, types.ParsingError(-s), ""}
self.setErr(err)
return
Expand All @@ -95,7 +86,6 @@ func (self *StreamDecoder) Decode(val interface{}) (err error) {
e = x + s
}

// println("decode: ", s, e)
// must copy string here for safety
self.Decoder.Reset(string(self.buf[s:e]))
err = self.Decoder.Decode(val)
Expand All @@ -107,13 +97,11 @@ func (self *StreamDecoder) Decode(val interface{}) (err error) {
self.scanp = e
_, empty := self.scan()
if empty {
// println("recycle")
// no remain valid bytes, thus we just recycle buffer
mem := self.buf
self.buf = nil
freeBytes(mem)
} else {
// println("keep")
// remain undecoded bytes, move them onto head
n := copy(self.buf, self.buf[self.scanp:])
self.buf = self.buf[:n]
Expand All @@ -129,7 +117,6 @@ func (self *StreamDecoder) Decode(val interface{}) (err error) {
// InputOffset returns the input stream byte offset of the current decoder position.
// The offset gives the location of the end of the most recently returned token and the beginning of the next token.
func (self *StreamDecoder) InputOffset() int64 {
// println("input offset",self.scanned, self.scanp)
return self.scanned + int64(self.scanp)
}

Expand Down Expand Up @@ -243,12 +230,10 @@ func realloc(buf *[]byte) bool {
l := uint(len(*buf))
c := uint(cap(*buf))
if c == 0 {
// println("use pool!")
*buf = bufPool.Get().([]byte)
return true
}
if c - l <= c >> minLeftBufferShift {
// println("realloc!")
e := l+(l>>minLeftBufferShift)
if e <= c {
e = c*2
Expand Down
2 changes: 0 additions & 2 deletions internal/decoder/api/stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ func BenchmarkDecodeStream_Sonic(b *testing.B) {
var str = _Double_JSON + strings.Repeat(" ", int(DefaultBufferSize-10)) + _Double_JSON
b.ResetTimer()
for i:=0; i<b.N; i++ {
// println("loop")
var r1 = strings.NewReader(str)
var v1 map[string]interface{}
dc := NewStreamDecoder(r1)
Expand All @@ -334,7 +333,6 @@ func BenchmarkDecodeStream_Sonic(b *testing.B) {
b.Run("small", func (b *testing.B) {
var str = _SMALL_JSON
for i:=0; i<b.N; i++ {
// println("one loop")
var r1 = strings.NewReader(str)
var v1 interface{}
dc := NewStreamDecoder(r1)
Expand Down
12 changes: 0 additions & 12 deletions internal/decoder/optdec/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,11 @@ func (s *bounedStack) Pop() (unsafe.Pointer, int, bool){
isObj := (s.stack[s.index].remain & (uint64(1) << 63)) != 0
s.stack[s.index].con = nil
s.stack[s.index].remain = 0
//println("pop inex is ", s.index, " len is ", len(s.stack), " p is ", con, " isobj ", isObj, " remain is ", remain)
return con, int(remain), isObj
}

//go:nosplit
func (s *bounedStack) Push(p unsafe.Pointer, remain int, isObj bool) {
//println("push inex is ", s.index, " len is ", len(s.stack), " p is ", p, " isobj ", isObj, " remain is ", remain)
// if s.index >= len(s.stack) {
// panic("slice len")
// }
s.stack[s.index].con = p
s.stack[s.index].remain = uint64(remain)
if isObj {
Expand Down Expand Up @@ -1034,7 +1029,6 @@ _object_key:
val = newSp
isObj = false
size = newSize
////println("new array size is ", newSize)
goto _arr_val;
case KStringCommon:
ctx.efacePool.ConvTstring(node.StringRef(ctx), val)
Expand Down Expand Up @@ -1084,7 +1078,6 @@ _object_key:
goto _object_key;
} else {
val = rt.PtrAdd(parent, rt.AnyType.Size)
//println("parent1 is ", parent, "val is ", val)
goto _arr_val;
}

Expand Down Expand Up @@ -1158,7 +1151,6 @@ _arr_val:

// check size
size -= 1
////println("remain arr size is ", size)
if size != 0 {
val = rt.PtrAdd(val, rt.AnyType.Size)
goto _arr_val;
Expand All @@ -1167,9 +1159,6 @@ _arr_val:

parent, size, isObj = ctx.Stack.Pop()


////println("parent is ", parent, "remain is ", size, " is obj ", isObj)

// parent is empty
if parent == nil {
if isObj {
Expand All @@ -1189,7 +1178,6 @@ _arr_val:
goto _object_key;
} else {
val = rt.PtrAdd(parent, rt.AnyType.Size)
//println("parent2 is ", parent, "val is ", val)
goto _arr_val;
}
}
Expand Down
2 changes: 0 additions & 2 deletions internal/encoder/vm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ func Execute(b *[]byte, p unsafe.Pointer, s *vars.Stack, flags uint64, prog *ir.
pc++
op := ins.Op()

// print_instr(buf, pc, op, ins, p)

switch op {
case ir.OP_goto:
pc = ins.Vi()
Expand Down
2 changes: 0 additions & 2 deletions internal/optcaching/fcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,7 @@ func (self *NormalFieldMap) getCaseInsensitive(name string) int {
offset := int(*(*int32)(unsafe.Pointer(uintptr(p) + uintptr(5 * len(name) + 1)))) + self.lowOffset
for i := 0; i < cnt; i++ {
key := rt.Mem2Str(self.keys[offset: offset + len(name)])
println("compare with loer is ---> ket is ", key, lower)
if key == lower {
println("compare with loer is ---> ket is inde is ", key, lower, int(self.keys[offset + len(name)]))
return int(self.keys[offset + len(name)])
}
offset += len(name) + 1
Expand Down
Loading