about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAriel Davis <ariel.z.davis@icloud.com>2023-05-06 01:03:18 -0700
committerAriel Davis <ariel.z.davis@icloud.com>2023-05-06 01:03:18 -0700
commitd683e220214f182ec788f86d3e005827a8a2648c (patch)
tree0111bef158404892659d2a7442e1d51de7cddab3
parent8012acc90e6d6ba0e59bb0513dc419a3aa4739bb (diff)
downloadrust-d683e220214f182ec788f86d3e005827a8a2648c.tar.gz
rust-d683e220214f182ec788f86d3e005827a8a2648c.zip
Use u32 more
-rw-r--r--lib/line-index/src/lib.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/line-index/src/lib.rs b/lib/line-index/src/lib.rs
index 26287212e31..527ba08717a 100644
--- a/lib/line-index/src/lib.rs
+++ b/lib/line-index/src/lib.rs
@@ -66,7 +66,7 @@ impl WideChar {
     }
 
     /// Returns the length in UTF-16 or UTF-32 code units.
-    fn wide_len(&self, enc: WideEncoding) -> usize {
+    fn wide_len(&self, enc: WideEncoding) -> u32 {
         match enc {
             WideEncoding::Utf16 => {
                 if self.len() == TextSize::from(4) {
@@ -75,7 +75,6 @@ impl WideChar {
                     1
                 }
             }
-
             WideEncoding::Utf32 => 1,
         }
     }
@@ -157,12 +156,11 @@ impl LineIndex {
 
     /// Transforms the `LineCol` with the given `WideEncoding` into a `WideLineCol`.
     pub fn to_wide(&self, enc: WideEncoding, line_col: LineCol) -> Option<WideLineCol> {
-        let col: TextSize = line_col.col.into();
-        let mut res: usize = col.into();
+        let mut col = line_col.col;
         if let Some(wide_chars) = self.line_wide_chars.get(&line_col.line) {
             for c in wide_chars.iter() {
                 if u32::from(c.end) <= line_col.col {
-                    res -= usize::from(c.len()) - c.wide_len(enc);
+                    col -= u32::from(c.len()) - c.wide_len(enc);
                 } else {
                     // From here on, all utf16 characters come *after* the character we are mapping,
                     // so we don't need to take them into account
@@ -170,7 +168,7 @@ impl LineIndex {
                 }
             }
         }
-        Some(WideLineCol { line: line_col.line, col: res as u32 })
+        Some(WideLineCol { line: line_col.line, col })
     }
 
     /// Transforms the `WideLineCol` with the given `WideEncoding` into a `LineCol`.