Remove offset_map from source_text to indexed_source_text
commit3b0386bb27fb37e67c2dc00343f1ca60ff19f9c4
authorSteve Cao <shiqicao@fb.com>
Mon, 26 Aug 2019 07:06:28 +0000 (26 00:06 -0700)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Mon, 26 Aug 2019 07:10:25 +0000 (26 00:10 -0700)
tree195db6ea7f60f93d98f7b45d1fbf186563c50bee
parent1bdb29434fcb863c771c2fb4b8681e89f2a1235d
Remove offset_map from source_text to indexed_source_text

Summary:
offset_map is added for quickly converting offset to row/column number, it is used after parsing. Rust also provides API for scanning trivia and parse mode, Ocaml calls these APIs with a pointer to source text and Rust references it without memory copy. After offset_map added to source_text, constructing source_text becomes O(n), n is text size.

This fix adds a new struct which references source text and owns line break map, APIs require indexing should be exposed through IndexedSourceText.

Reviewed By: dabek

Differential Revision: D17000526

fbshipit-source-id: 2a918fe27d457287536d292c97817001a97a958b
hphp/hack/src/parser/indexed_source_text.rs [new file with mode: 0644]
hphp/hack/src/parser/parser_core_types_lib.rs
hphp/hack/src/parser/positioned_syntax.rs
hphp/hack/src/parser/source_text.rs