aboutsummaryrefslogtreecommitdiff
path: root/http_handle_repo_tree.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-04-05 14:09:15 +0800
committerRunxi Yu <me@runxiyu.org>2025-04-05 14:09:15 +0800
commit98826d198b228e725ceb5a9fcf1d936ad3817d8e (patch)
treeba1840795c2b46529128945f80a548f11daf9c00 /http_handle_repo_tree.go
parentReduce allocations when converting string to []byte (diff)
downloadforge-0.1.22.tar.gz
forge-0.1.22.tar.zst
forge-0.1.22.zip
Reduce unnecessary allocations when converting []byte to stringv0.1.22
Diffstat (limited to 'http_handle_repo_tree.go')
-rw-r--r--http_handle_repo_tree.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/http_handle_repo_tree.go b/http_handle_repo_tree.go
index c834ad9..347026d 100644
--- a/http_handle_repo_tree.go
+++ b/http_handle_repo_tree.go
@@ -97,7 +97,7 @@ func httpHandleRepoTree(writer http.ResponseWriter, request *http.Request, param
}
files = append(files, displayTreeEntry{
- Name: string(name),
+ Name: bytesToString(name),
Mode: fmt.Sprintf("%06o", mode),
Size: size,
IsFile: typeCode == 2,
@@ -116,7 +116,7 @@ func httpHandleRepoTree(writer http.ResponseWriter, request *http.Request, param
errorPage500(writer, params, "error reading file content: "+err.Error())
return
}
- rendered := renderHighlightedFile(pathSpec, string(content))
+ rendered := renderHighlightedFile(pathSpec, bytesToString(content))
params["file_contents"] = rendered
renderTemplate(writer, "repo_tree_file", params)