dart-sdk/tests
Lasse R.H. Nielsen 164f8588d6 Optimize LineSplitter.
Avoid quadratic behavior when multiple chunks fail to
have a line break, and the carry-over string gets repeatedly extended.

In the original chunked conversion code, the chunk handling code retained the trailing, non-line-terminated text of the previous chunk, then eagerly concatenated it with the next chunk in order to continue looking for lines. That's moderately effective when lines are shorter than chunks, and neither are too large.
However, a very long line spread across many chunks would perform repeated string concatenation with quadratic time complexity.

This change gives `LineSplitter` the option of using a `StringBuffer` to collect multiple carry-over line parts.
The buffer is needed whenever a chunk does not contain a line break, and needs to be combined with a previous chunk's carry-over. This avoids ever directly concatenating any more than two strings.
The `StringBuffer` is not allocated until it's first needed, so if lines are generally shorter than chunks, the buffer won't be used. Once allocated, the buffer is retained in case a buffer will be needed again, but cleared when its contents are used.

The code optimizes for the simple case of each chunk having a line break.

Fixes #51167

Bug: https://github.com/dart-lang/sdk/issues/51167
Change-Id: I600a011e02aa9f1ad6f88e45764df5b2e8eccfa3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280100
Reviewed-by: Leaf Petersen <leafp@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-02-21 11:33:24 +00:00
..
co19 [dart2js, ddc] Skip flaky tests 2023-02-13 23:44:59 +00:00
co19_2 [dart2js, ddc] Skip flaky tests 2023-02-13 23:44:59 +00:00
corelib [dart2js, ddc] Skip flaky tests 2023-02-13 23:44:59 +00:00
corelib_2 [dart2js, ddc] Skip flaky tests 2023-02-13 23:44:59 +00:00
dartdevc [test_runner] Unify name for passing DDC options 2023-02-14 20:13:57 +00:00
dartdevc_2 [test_runner] Add new name for ddc compiler 2023-02-09 18:32:58 +00:00
ffi [vm] Fix Dart_CObject_Type breaking change 2023-02-20 11:59:19 +00:00
ffi_2 [vm] Fix Dart_CObject_Type breaking change 2023-02-20 11:59:19 +00:00
language Revert "Enforce current library restrictions." 2023-02-20 15:29:41 +00:00
language_2 Issue 51046. Implement primitive equality. 2023-02-18 06:22:04 +00:00
lib Optimize LineSplitter. 2023-02-21 11:33:24 +00:00
lib_2 Optimize LineSplitter. 2023-02-21 11:33:24 +00:00
modular [Reland][cfe] Support external constructor with final fields 2023-01-17 17:29:28 +00:00
standalone [test] Add missing resource dependency to web_socket_error_test. 2023-02-14 19:22:14 +00:00
standalone_2 Fix unbalanced call to Dart_TypedDataAcquireData. 2023-02-14 01:44:17 +00:00
web [test_runner] Unify name for passing DDC options 2023-02-14 20:13:57 +00:00
web_2 [test_runner] Unify name for passing DDC options 2023-02-14 20:13:57 +00:00
legacy_status_dart2js.csv Spelling tests 2022-12-19 12:56:47 +00:00
OWNERS [infra] Add OWNERS to the Dart SDK 2022-02-14 14:06:34 +00:00
README.md

This directory contains tests of the language and core library implementations. For more information, see https://github.com/dart-lang/sdk/wiki/Testing.