Skip to content

Commit 14e735b

Browse files
romtsnclaude
andcommitted
Address PR review feedback
- Revert cache version bump (4 stays, struct layout unchanged) - Make LineMapping.startline/endline Optional, remove has_minified_range - Extract startline/endline variables in cache find_members_and_rules Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e986607 commit 14e735b

File tree

4 files changed

+24
-35
lines changed

4 files changed

+24
-35
lines changed

src/builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ impl<'s> ParsedProguardMapping<'s> {
292292
None
293293
};
294294
let (mut startline, mut endline) = match line_mapping.as_ref() {
295-
Some(lm) if lm.has_minified_range => (Some(lm.startline), Some(lm.endline)),
296-
_ => (None, None),
295+
Some(lm) => (lm.startline, lm.endline),
296+
None => (None, None),
297297
};
298298
let (mut original_startline, mut original_endline) = match line_mapping {
299299
None => (None, None),

src/cache/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,10 +390,9 @@ impl<'data> ProguardCache<'data> {
390390
for member in mapping_entries {
391391
// Check if this member would produce a frame (line matching)
392392
let pf_line = prepared_frame.line.unwrap_or(0);
393-
if member.endline().unwrap_or(0) == 0
394-
|| (pf_line >= member.startline().unwrap_or(0) as usize
395-
&& pf_line <= member.endline().unwrap_or(0) as usize)
396-
{
393+
let startline = member.startline().unwrap_or(0) as usize;
394+
let endline = member.endline().unwrap_or(0) as usize;
395+
if endline == 0 || (pf_line >= startline && pf_line <= endline) {
397396
had_mappings = true;
398397
rewrite_rules.extend(self.decode_rewrite_rules(member));
399398
}

src/cache/raw.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub(crate) const PRGCACHE_MAGIC: u32 = u32::from_le_bytes(PRGCACHE_MAGIC_BYTES);
1919
pub(crate) const PRGCACHE_MAGIC_FLIPPED: u32 = PRGCACHE_MAGIC.swap_bytes();
2020

2121
/// The current version of the ProguardCache format.
22-
pub const PRGCACHE_VERSION: u32 = 5;
22+
pub const PRGCACHE_VERSION: u32 = 4;
2323

2424
/// The header of a proguard cache file.
2525
#[derive(Debug, Clone, PartialEq, Eq)]

src/mapping.rs

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -287,17 +287,14 @@ impl<'s> Iterator for ProguardRecordIter<'s> {
287287
/// All line mappings are 1-based and inclusive.
288288
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
289289
pub struct LineMapping {
290-
/// Start Line, 1-based.
291-
pub startline: usize,
292-
/// End Line, inclusive.
293-
pub endline: usize,
290+
/// Start Line, 1-based. `None` when no minified range prefix was present.
291+
pub startline: Option<usize>,
292+
/// End Line, inclusive. `None` when no minified range prefix was present.
293+
pub endline: Option<usize>,
294294
/// The original Start Line.
295295
pub original_startline: Option<usize>,
296296
/// The original End Line.
297297
pub original_endline: Option<usize>,
298-
/// Whether this mapping had an explicit minified line range prefix (e.g. `0:0:` or `1:5:`).
299-
/// `false` when the mapping line had no range prefix (e.g. `void method():42 -> a`).
300-
pub has_minified_range: bool,
301298
}
302299

303300
/// An R8 header, as described in
@@ -471,11 +468,10 @@ impl<'s> ProguardRecord<'s> {
471468
/// arguments: "",
472469
/// original_class: Some("com.example1.domain.MyBean"),
473470
/// line_mapping: Some(proguard::LineMapping {
474-
/// startline: 1016,
475-
/// endline: 1016,
471+
/// startline: Some(1016),
472+
/// endline: Some(1016),
476473
/// original_startline: Some(16),
477474
/// original_endline: Some(16),
478-
/// has_minified_range: true,
479475
/// }),
480476
/// })
481477
/// );
@@ -641,20 +637,18 @@ fn parse_proguard_field_or_method(
641637

642638
let line_mapping = match (startline, endline, original_startline) {
643639
(Some(startline), Some(endline), _) => Some(LineMapping {
644-
startline,
645-
endline,
640+
startline: Some(startline),
641+
endline: Some(endline),
646642
original_startline,
647643
original_endline,
648-
has_minified_range: true,
649644
}),
650645
// Preserve original line info even when no minified range is present.
651646
// This enables this crate to use the original line for no-line mappings.
652647
(None, None, Some(original_startline)) => Some(LineMapping {
653-
startline: 0,
654-
endline: 0,
648+
startline: None,
649+
endline: None,
655650
original_startline: Some(original_startline),
656651
original_endline,
657-
has_minified_range: false,
658652
}),
659653
_ => None,
660654
};
@@ -987,11 +981,10 @@ mod tests {
987981
arguments: "androidx.appcompat.widget.Toolbar",
988982
original_class: Some("androidx.appcompat.app.AppCompatDelegateImpl"),
989983
line_mapping: Some(LineMapping {
990-
startline: 14,
991-
endline: 15,
984+
startline: Some(14),
985+
endline: Some(15),
992986
original_startline: None,
993987
original_endline: None,
994-
has_minified_range: true,
995988
}),
996989
}),
997990
);
@@ -1010,11 +1003,10 @@ mod tests {
10101003
arguments: "androidx.appcompat.widget.Toolbar",
10111004
original_class: Some("androidx.appcompat.app.AppCompatDelegateImpl"),
10121005
line_mapping: Some(LineMapping {
1013-
startline: 14,
1014-
endline: 15,
1006+
startline: Some(14),
1007+
endline: Some(15),
10151008
original_startline: Some(436),
10161009
original_endline: None,
1017-
has_minified_range: true,
10181010
}),
10191011
}),
10201012
);
@@ -1033,11 +1025,10 @@ mod tests {
10331025
arguments: "androidx.appcompat.widget.Toolbar",
10341026
original_class: Some("androidx.appcompat.app.AppCompatDelegateImpl"),
10351027
line_mapping: Some(LineMapping {
1036-
startline: 14,
1037-
endline: 15,
1028+
startline: Some(14),
1029+
endline: Some(15),
10381030
original_startline: Some(436),
10391031
original_endline: Some(437),
1040-
has_minified_range: true,
10411032
}),
10421033
}),
10431034
);
@@ -1170,11 +1161,10 @@ androidx.activity.OnBackPressedCallback
11701161
arguments: "",
11711162
original_class: None,
11721163
line_mapping: Some(LineMapping {
1173-
startline: 1,
1174-
endline: 4,
1164+
startline: Some(1),
1165+
endline: Some(4),
11751166
original_startline: Some(184),
11761167
original_endline: Some(187),
1177-
has_minified_range: true,
11781168
}),
11791169
}),
11801170
Ok(ProguardRecord::R8Header(R8Header::Synthesized)),

0 commit comments

Comments
 (0)