深拷贝函数重构优化性能
This commit is contained in:
parent
230ddba3f6
commit
d8faa49866
|
|
@ -24,10 +24,21 @@ function print(Object) {
|
|||
/*
|
||||
* @函数作用: 深拷贝Table
|
||||
*/
|
||||
// function sq_DeepCopy(original) {
|
||||
// local Ret = Json.Encode(original);
|
||||
// Ret = Json.Decode(Ret);
|
||||
// return Ret;
|
||||
// }
|
||||
function sq_DeepCopy(original) {
|
||||
local Ret = Json.Encode(original);
|
||||
Ret = Json.Decode(Ret);
|
||||
return Ret;
|
||||
local RetTable = clone(original);
|
||||
foreach(Key, Value in original) {
|
||||
if (typeof Value == "table") {
|
||||
RetTable[Key] = sq_DeepCopy(Value);
|
||||
} else if (typeof Value == "array") {
|
||||
RetTable[Key] = sq_DeepCopy(Value);
|
||||
}
|
||||
}
|
||||
return RetTable;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in New Issue