short-paths: slight change to the penalty heuristic

Give the same penalty to ident containing double underscores as to ident
starting with an underscore.
master
Thomas Refis 2015-11-04 17:39:43 +00:00 committed by Thomas Refis
parent d7acc7989a
commit 3762abea10
1 changed files with 13 additions and 2 deletions

View File

@ -277,10 +277,21 @@ let rec normalize_type_path ?(cache=false) env p =
with
Not_found -> (p, Id)
let penalty s =
if s <> "" && s.[0] = '_' then
10
else
try
for i = 0 to String.length s - 2 do
if s.[i] = '_' && s.[i + 1] = '_' then
raise Exit
done;
1
with Exit -> 10
let rec path_size = function
Pident id ->
(let s = Ident.name id in if s <> "" && s.[0] = '_' then 10 else 1),
-Ident.binding_time id
penalty (Ident.name id), -Ident.binding_time id
| Pdot (p, _, _) ->
let (l, b) = path_size p in (1+l, b)
| Papply (p1, p2) ->