github.com/bytedance/sonic@v1.11.7-0.20240517092252-d2edb31b167b/ast/stubs.go (about) 1 /* 2 * Copyright 2021 ByteDance Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package ast 18 19 import ( 20 `unsafe` 21 `unicode/utf8` 22 23 `github.com/bytedance/sonic/internal/rt` 24 ) 25 26 //go:noescape 27 //go:linkname memmove runtime.memmove 28 //goland:noinspection GoUnusedParameter 29 func memmove(to unsafe.Pointer, from unsafe.Pointer, n uintptr) 30 31 //go:linkname unsafe_NewArray reflect.unsafe_NewArray 32 //goland:noinspection GoUnusedParameter 33 func unsafe_NewArray(typ *rt.GoType, n int) unsafe.Pointer 34 35 //go:nosplit 36 func mem2ptr(s []byte) unsafe.Pointer { 37 return (*rt.GoSlice)(unsafe.Pointer(&s)).Ptr 38 } 39 40 var ( 41 //go:linkname safeSet encoding/json.safeSet 42 safeSet [utf8.RuneSelf]bool 43 44 //go:linkname hex encoding/json.hex 45 hex string 46 ) 47 48 //go:linkname unquoteBytes encoding/json.unquoteBytes 49 func unquoteBytes(s []byte) (t []byte, ok bool)