diff options
author | 2023-08-13 14:27:29 +0100 | |
---|---|---|
committer | 2023-08-13 14:27:29 +0100 | |
commit | 8ea7f551a094c3cecbdd58e9d867ef19c0c547d7 (patch) | |
tree | eb501c8914c25dba21dbbffa8dc4302fd66a30ec /vendor/codeberg.org | |
parent | [bugfix] CSP policy fixes for S3/object storage (#2104) (diff) | |
download | gotosocial-8ea7f551a094c3cecbdd58e9d867ef19c0c547d7.tar.xz |
[bugfix] bump go-kv version with logfmt quote fix (#2108)
Diffstat (limited to 'vendor/codeberg.org')
-rw-r--r-- | vendor/codeberg.org/gruf/go-kv/README.md | 31 | ||||
-rw-r--r-- | vendor/codeberg.org/gruf/go-kv/benchmark.png | bin | 97592 -> 0 bytes | |||
-rw-r--r-- | vendor/codeberg.org/gruf/go-kv/format/README.md | 1 | ||||
-rw-r--r-- | vendor/codeberg.org/gruf/go-kv/format/format.go | 2 | ||||
-rw-r--r-- | vendor/codeberg.org/gruf/go-kv/format/util.go | 33 |
5 files changed, 45 insertions, 22 deletions
diff --git a/vendor/codeberg.org/gruf/go-kv/README.md b/vendor/codeberg.org/gruf/go-kv/README.md index fa4735868..ca66d2fd3 100644 --- a/vendor/codeberg.org/gruf/go-kv/README.md +++ b/vendor/codeberg.org/gruf/go-kv/README.md @@ -4,6 +4,33 @@ This library provides a key-value field structure `kv.Field{}` that plays well w The formatting for these key-value fields is handled by the `"fmt"` package by default. If you set the `kvformat` build tag then it will use a custom formatting library found under `format/`. You can see the benchmarks for both below. - +benchmarks: +``` +grufwub @ ~/Projects/main/go-kv +--> go test -run=none -benchmem -bench=.* +goos: linux +goarch: amd64 +pkg: codeberg.org/gruf/go-kv +cpu: 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz +BenchmarkFieldAppendMulti-8 125241 9389 ns/op 849 B/op 98 allocs/op +BenchmarkFieldStringMulti-8 113227 10444 ns/op 3029 B/op 120 allocs/op +BenchmarkFieldFprintfMulti-8 147915 7448 ns/op 1121 B/op 115 allocs/op +BenchmarkFieldsAppend-8 189126 6255 ns/op 849 B/op 98 allocs/op +BenchmarkFieldsString-8 166219 6517 ns/op 3798 B/op 100 allocs/op +PASS +ok codeberg.org/gruf/go-kv 6.169s -TODO: benchmarks comparing these to using `fmt.Sprintf("%q=%+v", ...)` yourself.
\ No newline at end of file +grufwub @ ~/Projects/main/go-kv +--> go test -run=none -benchmem -bench=.* -tags=kvformat +goos: linux +goarch: amd64 +pkg: codeberg.org/gruf/go-kv +cpu: 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz +BenchmarkFieldAppendMulti-8 190161 5709 ns/op 592 B/op 56 allocs/op +BenchmarkFieldStringMulti-8 161763 7930 ns/op 3240 B/op 95 allocs/op +BenchmarkFieldFprintfMulti-8 181557 6207 ns/op 1120 B/op 115 allocs/op +BenchmarkFieldsAppend-8 247052 4580 ns/op 592 B/op 56 allocs/op +BenchmarkFieldsString-8 231235 5103 ns/op 1768 B/op 58 allocs/op +PASS +ok codeberg.org/gruf/go-kv 6.134s +``` diff --git a/vendor/codeberg.org/gruf/go-kv/benchmark.png b/vendor/codeberg.org/gruf/go-kv/benchmark.png Binary files differdeleted file mode 100644 index 08d838643..000000000 --- a/vendor/codeberg.org/gruf/go-kv/benchmark.png +++ /dev/null diff --git a/vendor/codeberg.org/gruf/go-kv/format/README.md b/vendor/codeberg.org/gruf/go-kv/format/README.md index fe7b2338d..f27e229ef 100644 --- a/vendor/codeberg.org/gruf/go-kv/format/README.md +++ b/vendor/codeberg.org/gruf/go-kv/format/README.md @@ -2,4 +2,3 @@ String formatting package using Rust-style formatting directives, geared specifc Generally more visually friendly than `"fmt"` and performance is much improved. -
\ No newline at end of file diff --git a/vendor/codeberg.org/gruf/go-kv/format/format.go b/vendor/codeberg.org/gruf/go-kv/format/format.go index ab20e01f4..5027c7c06 100644 --- a/vendor/codeberg.org/gruf/go-kv/format/format.go +++ b/vendor/codeberg.org/gruf/go-kv/format/format.go @@ -316,7 +316,9 @@ func (f format) AppendStringSafe(s string) { f.Buffer.B = strconv.AppendQuote(f.Buffer.B, s) } else if ContainsDoubleQuote(s) { // Contains double quotes, needs escaping + f.Buffer.B = append(f.Buffer.B, '"') f.Buffer.B = AppendEscape(f.Buffer.B, s) + f.Buffer.B = append(f.Buffer.B, '"') } else if len(s) == 0 || ContainsSpaceOrTab(s) { // Contains space / empty, needs quotes f.Buffer.B = append(f.Buffer.B, '"') diff --git a/vendor/codeberg.org/gruf/go-kv/format/util.go b/vendor/codeberg.org/gruf/go-kv/format/util.go index b5c672ecb..f36727679 100644 --- a/vendor/codeberg.org/gruf/go-kv/format/util.go +++ b/vendor/codeberg.org/gruf/go-kv/format/util.go @@ -29,7 +29,7 @@ func IsSafeASCII(str string) bool { return true } -// ContainsSpaceOrTab checks if "s" contains space or tabs. +// ContainsSpaceOrTab checks if "s" contains space or tabs. EXPECTS ASCII. func ContainsSpaceOrTab(s string) bool { if i := strings.IndexByte(s, ' '); i >= 0 { return true // note using indexbyte as it is ASM. @@ -39,31 +39,26 @@ func ContainsSpaceOrTab(s string) bool { return false } -// ContainsDoubleQuote checks if "s" contains a double quote. +// ContainsDoubleQuote checks if "s" contains a double quote. EXPECTS ASCII. func ContainsDoubleQuote(s string) bool { return (strings.IndexByte(s, '"') >= 0) } -// AppendEscape will append 's' to 'dst' and escape any double quotes. +// AppendEscape will append 's' to 'dst' and escape any double quotes. EXPECTS ASCII. func AppendEscape(dst []byte, str string) []byte { - var delim bool for i := range str { - if str[i] == '\\' && !delim { - // Set delim flag - delim = true - continue - } else if str[i] == '"' && !delim { - // Append escaped double quote - dst = append(dst, `\"`...) - continue - } else if delim { - // Append skipped slash - dst = append(dst, `\`...) - delim = false - } + switch str[i] { + case '\\': + // Append delimited '\' + dst = append(dst, '\\', '\\') - // Append char as-is - dst = append(dst, str[i]) + case '"': + // Append delimited '"' + dst = append(dst, '\\', '"') + default: + // Append char as-is + dst = append(dst, str[i]) + } } return dst } |