remove copy
This commit is contained in:
parent
fd4fa0962e
commit
9b2dd35fa8
@ -146,7 +146,7 @@ class PositionManager:
|
||||
with self._lock:
|
||||
order = self.pending_orders.get(order_id)
|
||||
# 如果找到订单,返回它的副本而不是直接引用
|
||||
return order.copy() if order else None
|
||||
return order
|
||||
|
||||
def get_pending_orders(self):
|
||||
"""获取所有未完成委托
|
||||
@ -164,7 +164,7 @@ class PositionManager:
|
||||
# 锁外创建副本,避免外部修改影响内部数据
|
||||
result = {}
|
||||
for order_id, order in orders_copy.items():
|
||||
result[order_id] = order.copy() if hasattr(order, 'copy') else order
|
||||
result[order_id] = order
|
||||
|
||||
return result
|
||||
|
||||
@ -375,15 +375,4 @@ class PositionManager:
|
||||
Returns:
|
||||
list: 所有订单列表的副本
|
||||
"""
|
||||
# 创建临时变量存储锁内读取的数据
|
||||
orders_copy = []
|
||||
with self._lock:
|
||||
# 快速获取数据并立即释放锁
|
||||
orders_copy = self.all_orders.copy()
|
||||
|
||||
# 锁外创建深拷贝,避免外部修改影响内部数据
|
||||
result = []
|
||||
for order in orders_copy:
|
||||
result.append(order.copy() if hasattr(order, 'copy') else order)
|
||||
|
||||
return result
|
||||
return self.all_orders
|
||||
|
Loading…
x
Reference in New Issue
Block a user