Boost loading testcases speed and increase submission limit

This commit is contained in:
cuom1999 2020-09-27 01:56:48 -05:00
parent c3eb8eed9b
commit 37f8675f06
2 changed files with 9 additions and 4 deletions

View file

@ -137,6 +137,11 @@ def group_test_cases(cases):
return result
def read_head_archive(archive, file):
with archive.open(file) as f:
return f.read(settings.TESTCASE_VISIBLE_LENGTH + 3)
def get_visible_content(data):
data = data or b''
data = data.replace(b'\r\n', b'\r').replace(b'\r', b'\n')
@ -151,9 +156,9 @@ def get_visible_content(data):
def get_input_answer(case, archive):
result = {'input': '', 'answer': ''}
if (len(case.input_file)):
result['input'] = get_visible_content(archive.read(case.input_file))
result['input'] = get_visible_content(read_head_archive(archive, case.input_file))
if (len(case.output_file)):
result['answer'] = get_visible_content(archive.read(case.output_file))
result['answer'] = get_visible_content(read_head_archive(archive, case.output_file))
return result