From f513010b1a6d252c41183a16c4f71d519e70e3c3 Mon Sep 17 00:00:00 2001 From: dam Date: Sat, 11 May 2024 04:51:50 +0100 Subject: Code cleanup on import_from_csv. --- ttt.jai | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) (limited to 'ttt.jai') diff --git a/ttt.jai b/ttt.jai index afa769e..65a3cda 100644 --- a/ttt.jai +++ b/ttt.jai @@ -671,27 +671,25 @@ import_from_csv :: (db: *Database, path: string) -> bool #must { // Skip header line. consume_next_line(*csv); - { // Parse CSV lines. - line := csv; - while (true) { - auto_release_temp(); - - line, success := consume_next_line(*csv); - if success == false break; - - task: Task; - csv_values := split(line, ",",, temporary_allocator); - - // Truncate and import task name. - task_name := truncate(csv_values[0], task.name.count); - memcpy(task.name.data, task_name.data, task_name.count); - - advance(*csv_values); - for csv_values - task.times[it_index] = string_to_int(it); - - add_task(db, *task); - } + // Parse CSV lines. + while (true) { + auto_release_temp(); + + line, success := consume_next_line(*csv); + if success == false then break; + + task: Task; + csv_values := split(line, ",",, temporary_allocator); + + // Truncate and import task name. + task_name := truncate(csv_values[0], task.name.count); + memcpy(task.name.data, task_name.data, task_name.count); + + advance(*csv_values); + for csv_values + task.times[it_index] = string_to_int(it); + + add_task(db, *task); } // Adjust selected task. -- cgit v1.2.3