mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-06 03:53:50 +08:00
fast!!!
goos: windows goarch: amd64 pkg: github.com/Mrs4s/go-cqhttp/coolq cpu: Intel(R) Core(TM) i5-9300H CPU @ 2.40GHz BenchmarkCQBot_ConvertStringMessage-8 963939 1205 ns/op 368 B/op 11 allocs/op PASS ok github.com/Mrs4s/go-cqhttp/coolq 1.764s
This commit is contained in:
parent
62024a4403
commit
42e5b0564c
@ -359,7 +359,7 @@ func ToStringMessage(e []message.IMessageElement, id int64, isRaw ...bool) (r st
|
||||
// ConvertStringMessage 将消息字符串转为消息元素数组
|
||||
func (bot *CQBot) ConvertStringMessage(s string, isGroup bool) (r []message.IMessageElement) {
|
||||
var t, key string
|
||||
var d map[string]string
|
||||
var d = map[string]string{}
|
||||
ptr := unsafe.Pointer((*reflect.SliceHeader)(unsafe.Pointer(&s)).Data)
|
||||
l := len(s)
|
||||
i, j, CQBegin := 0, 0, 0
|
||||
@ -448,7 +448,9 @@ S1: // Plain Text
|
||||
}
|
||||
goto End
|
||||
S2: // CQCode Type
|
||||
d = make(map[string]string)
|
||||
for k := range d { // 内存复用,减小GC压力
|
||||
delete(d, k)
|
||||
}
|
||||
for ; i < l; i++ {
|
||||
switch *(*byte)(add(ptr, uintptr(i))) {
|
||||
case ',': // CQ Code with params
|
||||
|
Loading…
x
Reference in New Issue
Block a user