Compare commits

...

1 Commits
v1.5.1 ... main

Author SHA1 Message Date
AI Engineer
77e73281ad fix: revert EncodeInt to return []byte for performance (by AI) 2026-06-08 22:18:52 +08:00
3 changed files with 15 additions and 6 deletions

View File

@ -1,5 +1,12 @@
# Changelog: @go/encoding
## v1.5.2 (2026-06-08)
- **回滚与修复**: 修正了 `v1.5.1` 中架构设计的失误,将 Go 核心层的 `EncodeInt``IntEncoder.EncodeInt` 返回值从 `string` 恢复为 `[]byte`,彻底消除由于频繁强制转换导致的内存逃逸,恢复了高频并发场景下的零拷贝性能基准。
- **JS 智能桥接**: 通过在 `js_export.go` 的注册阶段采用匿名闭包函数 `func(u uint64) string`,完美兼顾了底层的高效性和 JS 环境面向字符串开发的友好体验。
## v1.5.1 (2026-06-08)
- **JS 对齐**: 将所有注册到 `jsmod` 的导出方法名统一为 PascalCase并将缩写名称如 URL, HTML, UTF8全大写以消除 JS 与 Go 调用体感上的摩擦。合并了冗余的 `xxxToString` 方法。
## [v1.3.2] - 2026-05-30
### Added

View File

@ -15,9 +15,9 @@ type IntEncoder struct {
decodeMap [256]int
}
// EncodeInt 将整数转换为字符串
func (enc *IntEncoder) EncodeInt(u uint64) string {
return string(enc.AppendInt(nil, u))
// EncodeInt 将整数转换为字节切片
func (enc *IntEncoder) EncodeInt(u uint64) []byte {
return enc.AppendInt(nil, u)
}
// AppendInt 将整数追加到已有字节切片中
@ -130,8 +130,8 @@ func NewIntEncoder(digits string, radix uint8) (*IntEncoder, error) {
var DefaultIntEncoder, _ = NewIntEncoder("9ukH1grX75TQS6LzpFAjIivsdZoO0mc8NBwnyYDhtMWEC2V3KaGxfJRPqe4lbU", 62)
var OrderedIntEncoder, _ = NewIntEncoder("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 62)
// EncodeInt 使用默认编码器将整数转换为字符串
func EncodeInt(u uint64) string {
// EncodeInt 使用默认编码器将整数转换为字节切片
func EncodeInt(u uint64) []byte {
return DefaultIntEncoder.EncodeInt(u)
}

View File

@ -18,7 +18,9 @@ func init() {
"HTMLUnescape": HTMLUnescape,
"UTF8Valid": UTF8Valid,
"SortJoin": SortJoin,
"EncodeInt": EncodeInt,
"EncodeInt": func(u uint64) string {
return string(EncodeInt(u))
},
"DecodeInt": DecodeInt,
"FillInt": FillInt,
"ExchangeInt": ExchangeInt,