only:minor improvement - do not rewrite file after each fragment

This commit is contained in:
rusefillc 2023-12-06 13:07:15 -05:00
parent 6cb7bc8c33
commit a45493eaad
3 changed files with 5 additions and 1 deletions

View File

@ -256,6 +256,7 @@ public class LiveDataProcessor {
wrapContent(lazyFile, sdCardFieldsConsumer.getBody());
lazyFile.close();
dataLogConsumer.endFile();
outputValueConsumer.endFile();
GetConfigValueConsumer.writeStringToFile(STATE_DICTIONARY_FACTORY_JAVA, stateDictionaryGenerator.getCompleteClass(), fileFactory);

View File

@ -54,7 +54,10 @@ public class DataLogConsumer implements ConfigurationConsumer {
String content = iterator.getContent();
tsWriter.append(content);
}
}
@Override
public void endFile() throws IOException {
writeStringToFile(fileName, tsWriter);
}

View File

@ -32,7 +32,7 @@ public class StateDictionaryGeneratorTest {
TestFileCaptor captor = new TestFileCaptor();
LiveDataProcessor liveDataProcessor = new LiveDataProcessor("test", fileName -> new StringReader(""), captor);
liveDataProcessor.handleYaml(data);
assertEquals(9, captor.fileCapture.size());
assertEquals("number of outputs", 10, captor.fileCapture.size());
assertEquals(" stateDictionary.register(live_data_e.LDS_output_channels, TsOutputs.VALUES, \"status_loop\");\n" +
" stateDictionary.register(live_data_e.LDS_fuel_computer, FuelComputer.VALUES, \"fuel_computer\");\n", liveDataProcessor.stateDictionaryGenerator.content.toString());