mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-06 12:03:50 +08:00
Merge pull request #660 from wdvxdr1123/patch/cqcode_fast
Accelerate cqcode again!
This commit is contained in:
commit
550e8d3531
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -41,7 +41,7 @@ jobs:
|
|||||||
if $IS_PR ; then echo $PR_PROMPT; fi
|
if $IS_PR ; then echo $PR_PROMPT; fi
|
||||||
export BINARY_NAME="$BINARY_PREFIX$GOOS_$GOARCH$BINARY_SUFFIX"
|
export BINARY_NAME="$BINARY_PREFIX$GOOS_$GOARCH$BINARY_SUFFIX"
|
||||||
export CGO_ENABLED=0
|
export CGO_ENABLED=0
|
||||||
go build -o "output/$BINARY_NAME" -ldflags "$LD_FLAGS" .
|
go build -o "output/$BINARY_NAME" -trimpath -ldflags "$LD_FLAGS" .
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
if: ${{ !github.head_ref }}
|
if: ${{ !github.head_ref }}
|
||||||
|
1
.github/workflows/release.yml
vendored
1
.github/workflows/release.yml
vendored
@ -31,5 +31,6 @@ jobs:
|
|||||||
goos: ${{ matrix.goos }}
|
goos: ${{ matrix.goos }}
|
||||||
goarch: ${{ matrix.goarch }}
|
goarch: ${{ matrix.goarch }}
|
||||||
goversion: "https://golang.org/dl/go1.16.linux-amd64.tar.gz"
|
goversion: "https://golang.org/dl/go1.16.linux-amd64.tar.gz"
|
||||||
|
build_flags: -trimpath
|
||||||
ldflags: -w -s -X "github.com/Mrs4s/go-cqhttp/coolq.Version=${{ env.RELEASE_VERSION }}"
|
ldflags: -w -s -X "github.com/Mrs4s/go-cqhttp/coolq.Version=${{ env.RELEASE_VERSION }}"
|
||||||
|
|
||||||
|
@ -359,7 +359,7 @@ func ToStringMessage(e []message.IMessageElement, id int64, isRaw ...bool) (r st
|
|||||||
// ConvertStringMessage 将消息字符串转为消息元素数组
|
// ConvertStringMessage 将消息字符串转为消息元素数组
|
||||||
func (bot *CQBot) ConvertStringMessage(s string, isGroup bool) (r []message.IMessageElement) {
|
func (bot *CQBot) ConvertStringMessage(s string, isGroup bool) (r []message.IMessageElement) {
|
||||||
var t, key string
|
var t, key string
|
||||||
var d map[string]string
|
var d = map[string]string{}
|
||||||
ptr := unsafe.Pointer((*reflect.SliceHeader)(unsafe.Pointer(&s)).Data)
|
ptr := unsafe.Pointer((*reflect.SliceHeader)(unsafe.Pointer(&s)).Data)
|
||||||
l := len(s)
|
l := len(s)
|
||||||
i, j, CQBegin := 0, 0, 0
|
i, j, CQBegin := 0, 0, 0
|
||||||
@ -448,7 +448,9 @@ S1: // Plain Text
|
|||||||
}
|
}
|
||||||
goto End
|
goto End
|
||||||
S2: // CQCode Type
|
S2: // CQCode Type
|
||||||
d = make(map[string]string)
|
for k := range d { // 内存复用,减小GC压力
|
||||||
|
delete(d, k)
|
||||||
|
}
|
||||||
for ; i < l; i++ {
|
for ; i < l; i++ {
|
||||||
switch *(*byte)(add(ptr, uintptr(i))) {
|
switch *(*byte)(add(ptr, uintptr(i))) {
|
||||||
case ',': // CQ Code with params
|
case ',': // CQ Code with params
|
||||||
|
Loading…
x
Reference in New Issue
Block a user