Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
burrbull committed Oct 31, 2023
1 parent 0c3fd42 commit 04ec2a3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/patch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,7 @@ fn check_offsets(offsets: &[u32], dim_increment: u32) -> bool {
true
}

/// Compare 2 strings and return index of first different char
fn first_diff(s1: &str, s2: &str) -> usize {
for ((i, c1), c2) in s1.char_indices().zip(s2.chars()) {
if c1 != c2 {
Expand All @@ -647,6 +648,7 @@ fn first_diff(s1: &str, s2: &str) -> usize {
}
s1.len().min(s2.len())
}
/// Replace first occurrence of `pat` in string starting from byte `i`
fn replacefirstfrom<'a>(s: &'a str, pat: &str, to: &str, i: usize) -> Cow<'a, str> {
if i >= s.len() {
s.into()
Expand All @@ -655,6 +657,8 @@ fn replacefirstfrom<'a>(s: &'a str, pat: &str, to: &str, i: usize) -> Cow<'a, st
format!("{s1}{}", &s2.replacen(pat, to, 1)).into()
}
}
/// Tries to get common description (or displayNames) for register/field array with "%s" in index position.
/// Returns `None` if incoming descriptions have more then 1 difference
fn common_description(descs: &[Option<&str>], dim_index: &[String]) -> Option<Option<String>> {
let mut start = 0;
if descs.len() > 1 {
Expand Down

0 comments on commit 04ec2a3

Please sign in to comment.