https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65536

--- Comment #9 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #2)
>   if (file_change)
>     {
>       if (prev_file)
>         linemap_add (line_table, LC_LEAVE, false, NULL, 0);
> 
>       linemap_add (line_table, LC_ENTER, false, current_file, current_line);
>     }
>   else if (line_change)
>     linemap_line_start (line_table, current_line, current_col);
> 
>   return linemap_position_for_column (line_table, current_col);

By the way, just doing 

    else if (line_change)
-     linemap_line_start (line_table, current_line, current_col);
+     linemap_line_start (line_table, current_line, current_col + 1);

    return linemap_position_for_column (line_table, current_col);

should reduce memory consumption (and perhaps speed) of the line_table by a
lot. You are basically saying: I need a map not bigger than current_col. Then
saying, give me a position for current_col, which triggers another map
allocation.

And my guess is that:

    else if (line_change)
-     linemap_line_start (line_table, current_line, current_col);
+     linemap_line_start (line_table, current_line, 81);

    return linemap_position_for_column (line_table, current_col);

may reduce it even further if at least the file:line are mostly in order
(otherwise, the column number does not matter because you will create a new map
for every call to linemap_line_start).

Reply via email to