Skip to content

Commit 27ce560

Browse files
committed
low.Appendf -> hfmt.Appendf
1 parent def9cc5 commit 27ce560

File tree

7 files changed

+23
-46
lines changed

7 files changed

+23
-46
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1
99
golang.org/x/term v0.29.0
1010
nikand.dev/go/cbor v0.0.0-20250217185914-a319e53bb3df
11-
nikand.dev/go/hacked v0.0.0-20250204131511-0939a5c9c782
11+
nikand.dev/go/hacked v0.0.0-20250303011940-bcd287f6db83
1212
tlog.app/go/eazy v0.4.2
1313
tlog.app/go/errors v0.11.0
1414
tlog.app/go/loc v0.7.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
6060
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
6161
nikand.dev/go/cbor v0.0.0-20250217185914-a319e53bb3df h1:VwrpIfkj/Q1xD2lzxfzf6HA1NqfBcDFu/jGiLOesWvQ=
6262
nikand.dev/go/cbor v0.0.0-20250217185914-a319e53bb3df/go.mod h1:KU6mV3VAVKdPXXlzE9BtpUaVtV+Z/N/jFEeC5jXMkDg=
63-
nikand.dev/go/hacked v0.0.0-20250204131511-0939a5c9c782 h1:ZwZD4yU0BtLJ3dIuFGxGrvgCshSqR5QtF3p48Qyjzzo=
64-
nikand.dev/go/hacked v0.0.0-20250204131511-0939a5c9c782/go.mod h1:1Rg61dFquIgf7q9N6J5su45CvGWn/cDG5x2gXzDN5G0=
63+
nikand.dev/go/hacked v0.0.0-20250303011940-bcd287f6db83 h1:9W6JKr4hAg2OuJoFYiMtRUwcLPwrW+I+YrMVk+Uh8VQ=
64+
nikand.dev/go/hacked v0.0.0-20250303011940-bcd287f6db83/go.mod h1:3/xzwKPKrKRkfShFa8jMa27vTMHQRqzgrkF6L1cdrJw=
6565
tlog.app/go/eazy v0.4.2 h1:Pa///lJlpkUUaApgI2A5xwtB+DnFG6ENDOtrRHDJsNk=
6666
tlog.app/go/eazy v0.4.2/go.mod h1:qk9DSaqsW9Kn4TXRxQn3VZrqmlvrTBSk753g0RQMUy0=
6767
tlog.app/go/errors v0.11.0 h1:tPziygVc2iyVVqYGirwSuxGLaYJ9yFE5gKGxtS30fKk=

low/fmt.go

Lines changed: 0 additions & 30 deletions
This file was deleted.

low/runtime.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ func InterfaceData(v interface{}) unsafe.Pointer {
2828
}
2929

3030
func UnsafeString(ptr unsafe.Pointer, l int) string {
31-
return *(*string)(unsafe.Pointer(&sh{p: ptr, l: l}))
31+
return unsafe.String((*byte)(ptr), l)
3232
}
3333

3434
func UnsafeBytesToString(b []byte) string {
35-
return *(*string)(unsafe.Pointer(&b))
35+
return unsafe.String(unsafe.SliceData(b), len(b))
3636
}
3737

3838
func NoEscapeBuffer(b []byte) []byte {

tlog.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,9 @@ func message(l *Logger, id ID, d int, msg interface{}, kvs []interface{}) {
174174
case []byte:
175175
l.b = e.AppendTagBytes(l.b, tlwire.String, msg)
176176
case format:
177-
l.b = e.AppendFormat(l.b, msg.Fmt, msg.Args...)
177+
l.b = e.AppendFormatf(l.b, msg.Fmt, msg.Args...)
178178
default:
179-
l.b = e.AppendFormat(l.b, "%v", msg)
179+
l.b = e.AppendFormat(l.b, msg)
180180
}
181181
}
182182

tlwire/encoder.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"time"
66

77
"nikand.dev/go/cbor"
8+
"nikand.dev/go/hacked/hfmt"
89
"nikand.dev/go/hacked/htime"
9-
"tlog.app/go/tlog/low"
1010
)
1111

1212
type (
@@ -160,15 +160,22 @@ func (e *Encoder) AppendAddrPort(b []byte, a netip.AddrPort) []byte {
160160
return b
161161
}
162162

163-
func (e *Encoder) AppendFormat(b []byte, format string, args ...interface{}) []byte {
163+
func (e *Encoder) AppendFormat(b []byte, args ...interface{}) []byte {
164164
b = append(b, byte(String))
165165
st := len(b)
166166

167-
if format == "" {
168-
b = low.Append(b, args...)
169-
} else {
170-
b = low.Appendf(b, format, args...)
171-
}
167+
b = hfmt.Append(b, args...)
168+
169+
l := len(b) - st
170+
171+
return e.InsertLen(b, st, l)
172+
}
173+
174+
func (e *Encoder) AppendFormatf(b []byte, format string, args ...interface{}) []byte {
175+
b = append(b, byte(String))
176+
st := len(b)
177+
178+
b = hfmt.Appendf(b, format, args...)
172179

173180
l := len(b) - st
174181

web/server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"time"
1616

1717
"nikand.dev/go/hacked/hnet"
18-
"nikand.dev/go/hacked/little"
18+
"nikand.dev/go/hacked/low"
1919
"tlog.app/go/eazy"
2020
"tlog.app/go/errors"
2121

@@ -165,7 +165,7 @@ func (s *Server) HandleRequest(ctx context.Context, rw http.ResponseWriter, req
165165
w = convert.NewLogfmt(w)
166166
case ".html":
167167
ww := convert.NewWeb(w)
168-
defer little.Closer(ww, &err, "close Web")
168+
defer low.Closer(ww, &err, "close Web")
169169

170170
w = ww
171171
default:

0 commit comments

Comments
 (0)