From b6adad3f87c6a8d3df734b6378793177974160cd Mon Sep 17 00:00:00 2001 From: Konrad Dysput Date: Mon, 22 Jan 2024 15:48:28 +0100 Subject: [PATCH] Add support for remove subrange --- Sources/Features/Breadcrumb/BacktraceBreadcrumbFile.swift | 5 +---- Sources/Features/Breadcrumb/Queue.swift | 5 ++++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/Features/Breadcrumb/BacktraceBreadcrumbFile.swift b/Sources/Features/Breadcrumb/BacktraceBreadcrumbFile.swift index d1fa945d..92f7b805 100644 --- a/Sources/Features/Breadcrumb/BacktraceBreadcrumbFile.swift +++ b/Sources/Features/Breadcrumb/BacktraceBreadcrumbFile.swift @@ -53,10 +53,7 @@ enum BacktraceBreadcrumbFileError: Error { let breadcrumbSize = queueBreadcrumb.size // Pop last element if size is greater than maxQueueFileSizeBytes if size + breadcrumbSize > maxQueueFileSizeBytes && !queue.isEmpty { - for breadcrumbsToRemove in (0...index).reversed() { - _ = queue.pop(at: breadcrumbsToRemove) - } - + queue.removeSubrange(range: (0...index)) break } let breadcrumbJsonData = queueBreadcrumb.json diff --git a/Sources/Features/Breadcrumb/Queue.swift b/Sources/Features/Breadcrumb/Queue.swift index ab1bf5e9..9b8ec6df 100644 --- a/Sources/Features/Breadcrumb/Queue.swift +++ b/Sources/Features/Breadcrumb/Queue.swift @@ -20,6 +20,10 @@ public class Queue: NSObject { return elements.first } + func removeSubrange(range: ClosedRange) { + elements.removeSubrange(range); + } + func remove(at index: Int) -> T? { guard index < elements.count else { return nil @@ -28,7 +32,6 @@ public class Queue: NSObject { if (index < 0) { return nil } - return elements.remove(at: index) }