cast/CHANGELOG.md

54 lines
3.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# CHANGELOG
## [v1.2.1] - 2026-05-04
### Added
- **Encoder 元数据缓存**: 引入 `encoderStructDescriptor` 缓存,大幅减少结构体序列化时的反射开销。
- **time.Time 全局支持**:
- Encoder/Decoder 原生支持 `time.Time` 类型。
- 默认使用格式 `2006-01-02 15:04:05.000`
- 支持通过 Struct Tag 指定格式(如 `json:"format=2006-01-02"`)。
- **零分配摩擦匹配**: 重构 Decoder 匹配逻辑,实现 `normalizeEqual` 算法,在忽略大小写/下划线匹配时彻底消除内存分配。
### Optimized
- **Encoder 性能**:
- 采用 `MapRange` 代替 `MapKeys` 遍历 Map减少中间切片分配。
- 延迟 Path 路径计算,仅在开启脱敏字典时计算路径。
- 重写 `writeString`,支持批量写入与高效查表转义。
- **Decoder 性能**:
- 优化 `decodeArray` 扩容策略,优先尊重并使用用户预设的 Capacity。
- **移除 Map 排序**: 序列化 Map 时不再进行 Key 排序,显著提升大规模 Map 的处理速度。
## [v1.2.0] - 2026-05-04
### Added
- **零摩擦 API**: 核心 API `To[T]`, `ToJSON`, `FromJSON`, `ToMap`, `ToSlice` 全部重构为**不返回错误**,遇错静默返回零值。
- **As 包装器**: 原 `Quiet` 更名为 `As`,用于一键消除传统 `(value, error)` 函数的摩擦。
### Removed
- **YAML 支持**: 移除 `gopkg.in/yaml.v3` 依赖。
- **Must/As[T] 系列**: 移除 `Must` 及所有特殊的 `AsXxx` 系列函数,统一通过 `To[T]``As` 包装实现。
- **冗余 API**: 移除 `PrettyToJSONBytes``ToJSONDesensitize`,保留对应的 `PrettyToJSON``ToJSONDesensitizeBytes`
## [v1.1.2] - 2026-05-04
### Added
- 新增 `ToMap``ToSlice`: 侧重于原地填充/追加,支持 Struct 继承拍平、KV 序列化与自动类型转换。
- 新增 `MakeMap`, `MakeSlice`, `FromJSON`, `FromYAML` 系列: 泛型构建新对象的零摩擦 API。
- 增强 `UnmarshalJSON` / `UnmarshalYAML`: 重构为副作用模式(返回 error支持多种输入类型。
### Removed
- 移除 `Ints``Strings`: 由更通用的 `MakeSlice` 替代,保持 API 简洁。
## [v1.1.1] - 2026-04-12
- **修复**: 解决 `FastEncoder` 在编码结构体时忽略匿名嵌入Embedded字段的问题确保组合对象的完整序列化。
## [v1.1.0] - 2026-05-02
- **功能**: 新增 `FastEncoder`,实现单路径 JSON 编码,大幅提升性能并减少内存分配。
- **功能**: 新增 `ToJSONDesensitize``ToJSONDesensitizeBytes`,支持原生字段脱敏。
- **功能**: 新增 `FastDecoder`,实现单路径流式 JSON 解析,支持“零摩擦” Key 匹配(大小写不敏感、归一化映射)。
- **优化**: 完善 `null` 值处理逻辑,区分 `nil` 指针与空 `slice`/`map`
- **重构**: 移除旧版 `makeJSONType` 等冗余逻辑,代码结构更简洁高效。
## [v1.0.4] - 2026-04-30
- **优化**: 重构 `UniqueAppend`,改用 Map 查重,性能提升至 $O(n)$。
- **优化**: 提升 `If` 函数参数描述性,符合工程规范。
- **优化**: 精简 `parseInt`/`parseUint` 逻辑,减少冗余字符串扫描。
- **优化**: 优化 `FixUpperCase` 内部字符处理,引入位运算提升效率。