summaryrefslogtreecommitdiffstats
path: root/perl_checker.src/info.ml
diff options
context:
space:
mode:
Diffstat (limited to 'perl_checker.src/info.ml')
-rw-r--r--perl_checker.src/info.ml11
1 files changed, 7 insertions, 4 deletions
diff --git a/perl_checker.src/info.ml b/perl_checker.src/info.ml
index d15d3c0..947dc50 100644
--- a/perl_checker.src/info.ml
+++ b/perl_checker.src/info.ml
@@ -2,18 +2,21 @@ open List
open Printf
open Common
-let (lines_starts : (string * int list ref) list ref) = ref []
+let (lines_starts : (string, int list) Hashtbl.t) = Hashtbl.create 4
let current_file_lines_starts = ref []
let current_file_current_line = ref 0
let current_file = ref ""
let start_a_new_file file =
+ if !current_file <> "" then Hashtbl.add lines_starts !current_file !current_file_lines_starts ;
current_file := file ;
- current_file_lines_starts := [0] ;
- lines_starts := (file, current_file_lines_starts) :: !lines_starts
+ current_file_lines_starts := [0]
+
+let get_lines_starts_for_file file =
+ if file = !current_file then !current_file_lines_starts else Hashtbl.find lines_starts file
let raw_pos2raw_line file a =
- let starts = map_index (fun a b -> a,b) (rev !(assoc file !lines_starts)) in
+ let starts = map_index (fun a b -> a,b) (rev (get_lines_starts_for_file file)) in
let ((offset, line), _) = find (fun (_,(e,_)) -> e > a) (combine starts (tl starts @ [999999999, 999999999])) in
line, offset