diff options
| author | Michael Woerister <michaelwoerister@posteo.net> | 2016-08-24 17:06:31 -0400 |
|---|---|---|
| committer | Michael Woerister <michaelwoerister@posteo.net> | 2016-09-01 09:43:44 -0400 |
| commit | e355ec1c6a24f8a597a08809b9dad394498dc3dd (patch) | |
| tree | 8ac8b42b5e30e3e63bbbfdc76d15faa3fb3b1fe5 /src/libsyntax | |
| parent | 8e4f4810dcc7cc21aec13d421d211a94f29e413f (diff) | |
| download | rust-e355ec1c6a24f8a597a08809b9dad394498dc3dd.tar.gz rust-e355ec1c6a24f8a597a08809b9dad394498dc3dd.zip | |
incr.comp.: Add stable hashing of HIR spans to ICH.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/codemap.rs | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index b176b8fefc6..cd6f2874954 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -348,26 +348,10 @@ impl CodeMap { let files = self.files.borrow(); let f = (*files)[idx].clone(); - let len = f.lines.borrow().len(); - if len == 0 { - return Err(f); + match f.lookup_line(pos) { + Some(line) => Ok(FileMapAndLine { fm: f, line: line }), + None => Err(f) } - - let mut a = 0; - { - let lines = f.lines.borrow(); - let mut b = lines.len(); - while b - a > 1 { - let m = (a + b) / 2; - if (*lines)[m] > pos { - b = m; - } else { - a = m; - } - } - assert!(a <= lines.len()); - } - Ok(FileMapAndLine { fm: f, line: a }) } pub fn lookup_char_pos_adj(&self, pos: BytePos) -> LocWithOpt { @@ -691,7 +675,7 @@ impl CodeMap { } // Return the index of the filemap (in self.files) which contains pos. - fn lookup_filemap_idx(&self, pos: BytePos) -> usize { + pub fn lookup_filemap_idx(&self, pos: BytePos) -> usize { let files = self.files.borrow(); let files = &*files; let count = files.len(); |
