mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
perf(sessions): reduce store clone allocations
This commit is contained in:
@@ -196,10 +196,21 @@ function cloneJsonLikeValue<T>(value: T): T {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
if (Array.isArray(value)) {
|
if (Array.isArray(value)) {
|
||||||
return value.map((item) => cloneJsonLikeValue(item)) as T;
|
const cloned = new Array(value.length);
|
||||||
|
for (let index = 0; index < value.length; index += 1) {
|
||||||
|
if (!(index in value)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
cloned[index] = cloneJsonLikeValue(value[index]);
|
||||||
|
}
|
||||||
|
return cloned as T;
|
||||||
}
|
}
|
||||||
const cloned: Record<string, unknown> = {};
|
const cloned: Record<string, unknown> = {};
|
||||||
for (const [key, child] of Object.entries(value as Record<string, unknown>)) {
|
for (const key in value as Record<string, unknown>) {
|
||||||
|
if (!Object.prototype.hasOwnProperty.call(value, key)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const child = (value as Record<string, unknown>)[key];
|
||||||
if (child === undefined) {
|
if (child === undefined) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user