Skip to content

Commit 78cffe1

Browse files
authored
GD-336: Improve test suite parsing for large function descriptors (#342)
* GD-336: Improve test suite parsing for large function descriptors # Why Loading of a test suite with an parameterized test and a huge parameter set was resulting in extrem long loading time # What Simplifyed the function descriptor parsing to speedup loading time.
1 parent 5509ad3 commit 78cffe1

File tree

2 files changed

+6
-18
lines changed

2 files changed

+6
-18
lines changed

addons/gdUnit3/src/core/parse/GdScriptParser.gd

+5-18
Original file line numberDiff line numberDiff line change
@@ -522,10 +522,9 @@ func extract_source_code(script_path :PoolStringArray) -> PoolStringArray:
522522
func extract_func_signature(rows :PoolStringArray, index :int) -> String:
523523
var signature = ""
524524
for rowIndex in range(index, rows.size()):
525-
var row :String = rows[rowIndex]
526-
signature += row.trim_prefix("\t").trim_suffix("\t")
525+
signature += rows[rowIndex].strip_edges()
527526
if is_func_end(signature):
528-
return clean_up_row(signature).replace("\n", "")
527+
return clean_up_row(signature)
529528
push_error("Can't fully extract function signature of '%s'" % rows[index])
530529
return ""
531530

@@ -642,22 +641,10 @@ func is_static_func(func_signature :String) -> bool:
642641
func is_inner_class(clazz_path :PoolStringArray) -> bool:
643642
return clazz_path.size() > 1
644643

644+
645645
func is_func_end(row :String) -> bool:
646-
var input := clean_up_row(row)
647-
var current_index = 0
648-
var token :Token = null
649-
while current_index < len(input):
650-
# function ends without return type definition
651-
if TOKEN_FUNCTION_END.match(input, current_index):
652-
return true
653-
# function ends with return type definition
654-
if TOKEN_FUNCTION_RETURN_TYPE.match(input, current_index):
655-
return true
656-
token = next_token(input, current_index) as Token
657-
if token == TOKEN_NOT_MATCH:
658-
return false
659-
current_index += token._consumed
660-
return false
646+
return row.strip_edges(false, true).ends_with(":")
647+
661648

662649
func _patch_inner_class_names(value :String, clazz_name :String) -> String:
663650
var patch := value

addons/gdUnit3/test/core/parse/GdScriptParserTest.gd

+1
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ func test_is_func_end() -> void:
439439
assert_bool(_parser.is_func_end(" ):")).is_true()
440440
assert_bool(_parser.is_func_end(" -> void:")).is_true()
441441
assert_bool(_parser.is_func_end(" ) -> void :")).is_true()
442+
assert_bool(_parser.is_func_end("func test_a(arg1, arg2 = {1:2} ):")).is_true()
442443

443444
func test_extract_func_signature_multiline() -> void:
444445
var source_code = [

0 commit comments

Comments
 (0)