From fb69335578b9940d76dd33e89ad5bf101c55d9a9 Mon Sep 17 00:00:00 2001 From: "Samuel EF. Tinnerholm" Date: Sun, 24 May 2026 19:48:31 +0300 Subject: [PATCH] =?UTF-8?q?perf:=20replace=20O(n=C2=B2)=20spread=20with=20?= =?UTF-8?q?push=20in=20smarkets=20fetcher?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #355 --- core/src/exchanges/smarkets/fetcher.ts | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/core/src/exchanges/smarkets/fetcher.ts b/core/src/exchanges/smarkets/fetcher.ts index c8f78e7f..a52bde64 100644 --- a/core/src/exchanges/smarkets/fetcher.ts +++ b/core/src/exchanges/smarkets/fetcher.ts @@ -403,14 +403,22 @@ export class SmarketsFetcher implements IExchangeFetcher(); for (const market of allMarkets) { - const existing = marketsByEvent.get(market.event_id) || []; - marketsByEvent.set(market.event_id, [...existing, market]); + const existing = marketsByEvent.get(market.event_id); + if (existing) { + existing.push(market); + } else { + marketsByEvent.set(market.event_id, [market]); + } } const contractsByMarket = new Map(); for (const contract of allContracts) { - const existing = contractsByMarket.get(contract.market_id) || []; - contractsByMarket.set(contract.market_id, [...existing, contract]); + const existing = contractsByMarket.get(contract.market_id); + if (existing) { + existing.push(contract); + } else { + contractsByMarket.set(contract.market_id, [contract]); + } } const volumesByMarket = new Map(); @@ -443,7 +451,7 @@ export class SmarketsFetcher implements IExchangeFetcher, targetCount?: number ): Promise { - let allEvents: SmarketsRawEvent[] = []; + const allEvents: SmarketsRawEvent[] = []; let lastId: string | undefined; let page = 0; @@ -461,7 +469,7 @@ export class SmarketsFetcher implements IExchangeFetcher