From 4cb3df5e7ef737e6b23d03a5ad0777fd5e737f6c Mon Sep 17 00:00:00 2001 From: Yves Dubois Date: Sat, 29 May 2021 21:36:24 -0400 Subject: [PATCH] Performance increase for `refresh_story` on large stories --- aiserver.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/aiserver.py b/aiserver.py index 7203b472..639d157b 100644 --- a/aiserver.py +++ b/aiserver.py @@ -1090,12 +1090,10 @@ def applyoutputformatting(txt): # Sends the current story content to the Game Screen #==================================================================# def refresh_story(): - txt = ''+vars.prompt+'' - i = 1 - for item in vars.actions: - txt = txt + ''+item+'' - i += 1 - emit('from_server', {'cmd': 'updatescreen', 'data': formatforhtml(txt)}) + text_parts = ['', vars.prompt, ''] + for idx, item in enumerate(vars.actions, start=1): + text_parts.extend(('', item, '')) + emit('from_server', {'cmd': 'updatescreen', 'data': formatforhtml(''.join(text_parts))}) #==================================================================# # Sends the current generator settings to the Game Menu