Skip to content

Commit 0007c72

Browse files
romtsnclaude
andcommitted
Address PR review feedback
- Reverse pending_frames and pop from end instead of remove(0) - Add comment explaining intentional Some(0)/None asymmetry - Use let-else with .first() instead of is_empty + indexing Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 36778f8 commit 0007c72

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

src/cache/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ impl<'r, 'data> RemappedFrameIter<'r, 'data> {
898898
fn next_inner(&mut self) -> Option<StackFrame<'data>> {
899899
// Drain any buffered frames from multi-frame expansion first.
900900
if !self.pending_frames.is_empty() {
901-
return Some(self.pending_frames.remove(0));
901+
return self.pending_frames.pop();
902902
}
903903

904904
if let Some(frame) = self.fallback.take() {
@@ -917,8 +917,8 @@ impl<'r, 'data> RemappedFrameIter<'r, 'data> {
917917
members.as_slice(),
918918
self.outer_source_file,
919919
);
920-
if !frames.is_empty() {
921-
let first = frames.remove(0);
920+
frames.reverse();
921+
if let Some(first) = frames.pop() {
922922
self.pending_frames = frames;
923923
return Some(first);
924924
}
@@ -1133,8 +1133,8 @@ fn resolve_no_line_frames<'a>(
11331133
/// - **0:0 entries** (`startline().is_some()`): if any entry has a range
11341134
/// (`original_endline != original_startline`), all emit `Some(0)`;
11351135
/// otherwise each emits its `original_startline`.
1136-
/// - **No-range entries** (`startline().is_none()`): a single entry uses
1137-
/// its `original_startline` (or `Some(0)` for bare methods); multiple entries
1136+
/// - **No-range entries** (`startline().is_none()`): a single entry emits
1137+
/// its `original_startline` if > 0, otherwise `Some(0)`; multiple entries
11381138
/// with the same name collapse to one frame with `Some(0)`; different names
11391139
/// each emit `Some(0)` in original order.
11401140
fn resolve_base_entries<'a>(

src/mapper.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,9 @@ fn resolve_no_line_frames<'s>(
309309
}
310310

311311
// No base entries — fall back to all entries with output line 0.
312-
if mapping_entries.is_empty() {
312+
let Some(first) = mapping_entries.first() else {
313313
return;
314-
}
315-
let first = &mapping_entries[0];
314+
};
316315
let unambiguous = mapping_entries.iter().all(|m| m.original == first.original);
317316
if unambiguous {
318317
collected
@@ -335,8 +334,8 @@ fn resolve_no_line_frames<'s>(
335334
/// - **0:0 entries** (`startline.is_some()`): if any entry has a range
336335
/// (`original_endline != original_startline`), all emit `Some(0)`;
337336
/// otherwise each emits its `original_startline`.
338-
/// - **No-range entries** (`startline.is_none()`): a single entry uses
339-
/// its `original_startline` (or `Some(0)` for bare methods); multiple entries
337+
/// - **No-range entries** (`startline.is_none()`): a single entry emits
338+
/// its `original_startline` if > 0, otherwise `Some(0)`; multiple entries
340339
/// with the same name collapse to one frame with `Some(0)`; different names
341340
/// each emit `Some(0)` in original order.
342341
fn resolve_base_entries<'s>(
@@ -388,14 +387,10 @@ fn resolve_base_entries<'s>(
388387
} else if all_no_range_same_name {
389388
if !no_range_emitted {
390389
no_range_emitted = true;
391-
let line = if no_range_count > 1 {
392-
Some(0)
393-
} else if member.original_startline.unwrap_or(0) > 0 {
390+
let line = if no_range_count == 1 && member.original_startline.unwrap_or(0) > 0 {
394391
member.original_startline
395-
} else if member.original_startline.is_none() {
396-
Some(0)
397392
} else {
398-
None
393+
Some(0)
399394
};
400395
collected
401396
.frames

0 commit comments

Comments
 (0)