perf: hoist per-call allocations to package-level variables
- Move audioExtensions/audioTypes slices to package var in media.go - Use strconv.Itoa instead of fmt.Sprintf for int conversion - Replace inline regexp.MustCompile with existing reTaskLine var Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
d167c94cdd
commit
032f40a592
3 changed files with 9 additions and 6 deletions
|
|
@ -562,9 +562,8 @@ func (ms *MemoryStore) GetPlanContext() string {
|
|||
currentPhase := ms.GetCurrentPhase()
|
||||
totalPhases := ms.GetTotalPhases()
|
||||
|
||||
// Extract task description
|
||||
taskLine := ""
|
||||
if m := regexp.MustCompile(`(?m)^> Task:\s*(.+)`).FindStringSubmatch(content); len(m) >= 2 {
|
||||
if m := reTaskLine.FindStringSubmatch(content); len(m) >= 2 {
|
||||
taskLine = strings.TrimSpace(m[1])
|
||||
}
|
||||
|
||||
|
|
@ -660,7 +659,7 @@ func (ms *MemoryStore) FormatPlanDisplay() string {
|
|||
}
|
||||
|
||||
taskLine := ""
|
||||
if m := regexp.MustCompile(`(?m)^> Task:\s*(.+)`).FindStringSubmatch(content); len(m) >= 2 {
|
||||
if m := reTaskLine.FindStringSubmatch(content); len(m) >= 2 {
|
||||
taskLine = strings.TrimSpace(m[1])
|
||||
}
|
||||
status := ms.GetPlanStatus()
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/sipeed/picoclaw/pkg/utils"
|
||||
|
|
@ -111,7 +112,7 @@ func (c *ClawHubRegistry) Search(ctx context.Context, query string, limit int) (
|
|||
q := u.Query()
|
||||
q.Set("q", query)
|
||||
if limit > 0 {
|
||||
q.Set("limit", fmt.Sprintf("%d", limit))
|
||||
q.Set("limit", strconv.Itoa(limit))
|
||||
}
|
||||
u.RawQuery = q.Encode()
|
||||
|
||||
|
|
|
|||
|
|
@ -13,10 +13,13 @@ import (
|
|||
"github.com/sipeed/picoclaw/pkg/logger"
|
||||
)
|
||||
|
||||
var (
|
||||
audioExtensions = []string{".mp3", ".wav", ".ogg", ".m4a", ".flac", ".aac", ".wma"}
|
||||
audioTypes = []string{"audio/", "application/ogg", "application/x-ogg"}
|
||||
)
|
||||
|
||||
// IsAudioFile checks if a file is an audio file based on its filename extension and content type.
|
||||
func IsAudioFile(filename, contentType string) bool {
|
||||
audioExtensions := []string{".mp3", ".wav", ".ogg", ".m4a", ".flac", ".aac", ".wma"}
|
||||
audioTypes := []string{"audio/", "application/ogg", "application/x-ogg"}
|
||||
|
||||
for _, ext := range audioExtensions {
|
||||
if strings.HasSuffix(strings.ToLower(filename), ext) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue