1
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-16 21:56:40 -05:00

chore: make FastAbs comment more easy to understand (#6692)

This commit is contained in:
WeidiDeng 2024-11-15 11:49:42 +08:00 committed by GitHub
parent 37f0c4bfae
commit 6028ff27fa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View file

@ -24,6 +24,8 @@ import (
// FastAbs is an optimized version of filepath.Abs for Unix systems, // FastAbs is an optimized version of filepath.Abs for Unix systems,
// since we don't expect the working directory to ever change once // since we don't expect the working directory to ever change once
// Caddy is running. Avoid the os.Getwd() syscall overhead. // Caddy is running. Avoid the os.Getwd() syscall overhead.
// It's overall the same as stdlib's implementation, the difference
// being cached working directory.
func FastAbs(path string) (string, error) { func FastAbs(path string) (string, error) {
if filepath.IsAbs(path) { if filepath.IsAbs(path) {
return filepath.Clean(path), nil return filepath.Clean(path), nil

View file

@ -18,8 +18,10 @@ import (
"path/filepath" "path/filepath"
) )
// FastAbs can't be optimized on Windows because the // FastAbs can't be optimized on Windows because there
// syscall.FullPath function takes an input. // are special file paths that require the use of syscall.FullPath
// to handle correctly.
// Just call stdlib's implementation which uses that function.
func FastAbs(path string) (string, error) { func FastAbs(path string) (string, error) {
return filepath.Abs(path) return filepath.Abs(path)
} }