优化会话性能:减少存储克隆分配 · openclaw/openclaw@99b27cd
steipete
·
2026-05-28
·
via Recent Commits to openclaw:main
| 原文行号 | 差异行号 | 差异行变 |
|---|
@@ -196,10 +196,21 @@ function cloneJsonLikeValue<T>(value: T): T {
|
196 | 196 | return value; |
197 | 197 | } |
198 | 198 | if (Array.isArray(value)) { |
199 | | -return value.map((item) => cloneJsonLikeValue(item)) as T; |
| 199 | +const cloned = new Array(value.length); |
| 200 | +for (let index = 0; index < value.length; index += 1) { |
| 201 | +if (!(index in value)) { |
| 202 | +continue; |
| 203 | +} |
| 204 | +cloned[index] = cloneJsonLikeValue(value[index]); |
| 205 | +} |
| 206 | +return cloned as T; |
200 | 207 | } |
201 | 208 | const cloned: Record<string, unknown> = {}; |
202 | | -for (const [key, child] of Object.entries(value as Record<string, unknown>)) { |
| 209 | +for (const key in value as Record<string, unknown>) { |
| 210 | +if (!Object.prototype.hasOwnProperty.call(value, key)) { |
| 211 | +continue; |
| 212 | +} |
| 213 | +const child = (value as Record<string, unknown>)[key]; |
203 | 214 | if (child === undefined) { |
204 | 215 | continue; |
205 | 216 | } |
|
此內容由慣性聚合(RSS閱讀器)自動聚合整理,僅供閱讀參考。 原文來自 — 版權歸原作者所有。