Reduce and prevent unnecessary random-access to List

Random-access access to `List` when iterating is `O(n^2)` (`O(n)` when
accessing a single element)

* Removed subscript operator, in favor of a more explicit `get`
* Added conversion from `Iterator` to `ConstIterator`
* Remade existing operations into other solutions when applicable
This commit is contained in:
A Thousand Ships 2024-04-15 15:18:34 +02:00
parent 7ebc866418
commit 955d5affa8
No known key found for this signature in database
GPG key ID: 2033189A662F8BD7
103 changed files with 877 additions and 849 deletions

View file

@ -187,7 +187,7 @@ int test_main(int argc, char *argv[]) {
}
// Doctest runner.
doctest::Context test_context;
List<String> test_args;
LocalVector<String> test_args;
// Clean arguments of "--test" from the args.
for (int x = 0; x < argc; x++) {
@ -200,7 +200,7 @@ int test_main(int argc, char *argv[]) {
if (test_args.size() > 0) {
// Convert Godot command line arguments back to standard arguments.
char **doctest_args = new char *[test_args.size()];
for (int x = 0; x < test_args.size(); x++) {
for (uint32_t x = 0; x < test_args.size(); x++) {
// Operation to convert Godot string to non wchar string.
CharString cs = test_args[x].utf8();
const char *str = cs.get_data();
@ -212,7 +212,7 @@ int test_main(int argc, char *argv[]) {
test_context.applyCommandLine(test_args.size(), doctest_args);
for (int x = 0; x < test_args.size(); x++) {
for (uint32_t x = 0; x < test_args.size(); x++) {
delete[] doctest_args[x];
}
delete[] doctest_args;