Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@ readme = "README.md"
edition = "2021"

[features]
uuid = ["dep:uuid", "lazy_static"]
uuid = ["dep:uuid"]

[dependencies]
lazy_static = { version = "1.4.0", optional = true }
thiserror = "1.0.61"
uuid = { version = "1.0.0", features = ["v5"], optional = true }
watto = { version = "0.1.0", features = ["writer", "strings"] }

[dev-dependencies]
lazy_static = "1.4.0"
criterion = "0.4"

[[bench]]
Expand Down
7 changes: 4 additions & 3 deletions src/mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,10 @@ impl<'s> ProguardMapping<'s> {
/// The UUID is generated from a file checksum.
#[cfg(feature = "uuid")]
pub fn uuid(&self) -> Uuid {
lazy_static::lazy_static! {
static ref NAMESPACE: Uuid = Uuid::new_v5(&Uuid::NAMESPACE_DNS, b"guardsquare.com");
}
use std::sync::LazyLock;

static NAMESPACE: LazyLock<Uuid> =
LazyLock::new(|| Uuid::new_v5(&Uuid::NAMESPACE_DNS, b"guardsquare.com"));
// this internally only operates on bytes, so this is safe to do
Uuid::new_v5(&NAMESPACE, self.source)
}
Expand Down
21 changes: 12 additions & 9 deletions tests/basic.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
use lazy_static::lazy_static;
use std::sync::LazyLock;

use proguard::{ProguardCache, ProguardMapper, ProguardMapping, StackFrame};

static MAPPING: &[u8] = include_bytes!("res/mapping.txt");
lazy_static! {
static ref MAPPING_WIN: Vec<u8> = MAPPING

static MAPPING_WIN: LazyLock<Vec<u8>> = LazyLock::new(|| {
MAPPING
.iter()
.flat_map(|&byte| if byte == b'\n' {
vec![b'\r', b'\n']
} else {
vec![byte]
.flat_map(|&byte| {
if byte == b'\n' {
vec![b'\r', b'\n']
} else {
vec![byte]
}
})
.collect();
}
.collect()
});

#[test]
fn test_basic() {
Expand Down
20 changes: 11 additions & 9 deletions tests/r8.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
use lazy_static::lazy_static;
use std::sync::LazyLock;

use proguard::{ProguardMapper, ProguardMapping, StackFrame};

static MAPPING_R8: &[u8] = include_bytes!("res/mapping-r8.txt");
static MAPPING_R8_SYMBOLICATED_FILE_NAMES: &[u8] =
include_bytes!("res/mapping-r8-symbolicated_file_names.txt");

lazy_static! {
static ref MAPPING_WIN_R8: Vec<u8> = MAPPING_R8
static MAPPING_WIN_R8: LazyLock<Vec<u8>> = LazyLock::new(|| {
MAPPING_R8
.iter()
.flat_map(|&byte| if byte == b'\n' {
vec![b'\r', b'\n']
} else {
vec![byte]
.flat_map(|&byte| {
if byte == b'\n' {
vec![b'\r', b'\n']
} else {
vec![byte]
}
})
.collect();
}
.collect()
});

#[test]
fn test_basic_r8() {
Expand Down
Loading