Skip to content

Commit

Permalink
Add support for remove subrange
Browse files Browse the repository at this point in the history
  • Loading branch information
konraddysput committed Jan 22, 2024
1 parent 1e9f7af commit b6adad3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 1 addition & 4 deletions Sources/Features/Breadcrumb/BacktraceBreadcrumbFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion Sources/Features/Breadcrumb/Queue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ public class Queue<T>: NSObject {
return elements.first
}

func removeSubrange(range: ClosedRange<Int>) {
elements.removeSubrange(range);
}

func remove(at index: Int) -> T? {
guard index < elements.count else {
return nil
Expand All @@ -28,7 +32,6 @@ public class Queue<T>: NSObject {
if (index < 0) {
return nil
}

return elements.remove(at: index)
}

Expand Down

0 comments on commit b6adad3

Please sign in to comment.