fix: 修改多个处理函数的返回类型为指针类型,以提高内存使用效率并避免不必要的拷贝

This commit is contained in:
lixiangwuxian
2025-04-09 23:28:39 +08:00
parent 144034939c
commit 7f0560b56e
32 changed files with 211 additions and 210 deletions

View File

@@ -20,7 +20,7 @@ func init() {
handler.RegisterFrontMatchHandler("https://", plainTextUrlParser, constants.LEVEL_USER)
}
func plainTextUrlParser(msg model.Message) (reply model.Reply) {
func plainTextUrlParser(msg model.Message) (reply *model.Reply) {
url := msg.RawMsg
url = strings.Split(url, " ")[0]
url = strings.Split(url, "\n")[0]
@@ -29,7 +29,7 @@ func plainTextUrlParser(msg model.Message) (reply model.Reply) {
url, _ = removeTrackingParams(url)
newUrl, err := resolveFinalURL(url)
if err != nil {
return model.Reply{
return &model.Reply{
ReplyMsg: "",
ReferOriginMsg: false,
FromMsg: msg,
@@ -37,31 +37,31 @@ func plainTextUrlParser(msg model.Message) (reply model.Reply) {
}
newUrl, _ = removeTrackingParams(newUrl)
if util.IsEquivalentURL(url, newUrl) {
return model.Reply{
return &model.Reply{
ReplyMsg: "",
ReferOriginMsg: false,
FromMsg: msg,
}
}
return model.Reply{
return &model.Reply{
ReplyMsg: newUrl,
ReferOriginMsg: true,
FromMsg: msg,
}
}
func cqJsonUrlParser(msg model.Message) (reply model.Reply) {
func cqJsonUrlParser(msg model.Message) (reply *model.Reply) {
newMsg := strings.ReplaceAll(msg.RawMsg, "\n", "")
qqdocurl, err := extractQQDocURL(newMsg)
if err != nil {
return model.Reply{
return &model.Reply{
ReplyMsg: "",
ReferOriginMsg: true,
FromMsg: msg,
}
}
return model.Reply{
return &model.Reply{
ReplyMsg: qqdocurl,
ReferOriginMsg: true,
FromMsg: msg,