diff --git a/Cargo.toml b/Cargo.toml index 347fcdc..929e7a2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,4 +48,11 @@ git2 = { version = "0.20.4", features = ["vendored-libgit2", "vendored-openssl"] openssl = { version = "0.10", features = ["vendored"] } [target.'cfg(windows)'.dependencies] -git2 = { version = "0.20.4", features = ["vendored-libgit2"] } \ No newline at end of file +git2 = { version = "0.20.4", features = ["vendored-libgit2"] } + +[profile.release] +opt-level = "z" +lto = true +codegen-units = 1 +panic = "abort" +strip = true \ No newline at end of file diff --git a/src/core/builder/common.rs b/src/core/builder/common.rs index 7527748..562cba2 100644 --- a/src/core/builder/common.rs +++ b/src/core/builder/common.rs @@ -329,17 +329,16 @@ pub fn needs_link(objects: &[String], output_path: &str) -> bool { fn parse_d_file(content: &str) -> Vec { let mut deps = Vec::new(); - let text = content.replace("\\\n", " ").replace("\\\r\n", " "); let mut target_end = 0; - let chars: Vec = text.chars().collect(); - for i in 0..chars.len() { - if chars[i] == ':' { + let bytes = content.as_bytes(); + for (i, &b) in bytes.iter().enumerate() { + if b == b':' { if i == 1 - && chars[0].is_ascii_alphabetic() - && i + 1 < chars.len() - && (chars[i + 1] == '\\' || chars[i + 1] == '/') + && bytes[0].is_ascii_alphabetic() + && i + 1 < bytes.len() + && (bytes[i + 1] == b'\\' || bytes[i + 1] == b'/') { - continue; // Windows drive letter + continue; } target_end = i + 1; break; @@ -347,17 +346,23 @@ fn parse_d_file(content: &str) -> Vec { } let deps_str = if target_end > 0 { - &text[target_end..] + &content[target_end..] } else { - &text + content }; let mut current_path = String::new(); let mut in_escape = false; + let mut chars = deps_str.chars().peekable(); - for c in deps_str.chars() { + while let Some(c) = chars.next() { if in_escape { - if c != '\n' && c != '\r' { + if c == '\n' { + } else if c == '\r' { + if chars.peek() == Some(&'\n') { + chars.next(); + } + } else { current_path.push(c); } in_escape = false;