From a929c86584fadaa84ae6fce0f622ba4941e06e11 Mon Sep 17 00:00:00 2001 From: Miika Turkia Date: Sun, 27 May 2018 16:56:09 +0300 Subject: [PATCH] Shearwater import: avoid running atoi multiple times Signed-off-by: Miika Turkia --- core/import-shearwater.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/core/import-shearwater.c b/core/import-shearwater.c index 2ad90cc7c..83d2fb2fa 100644 --- a/core/import-shearwater.c +++ b/core/import-shearwater.c @@ -82,6 +82,7 @@ extern int shearwater_profile_sample(void *handle, int columns, char **data, cha UNUSED(handle); UNUSED(columns); UNUSED(column); + int d6, d7; sample_start(); if (data[0]) @@ -98,12 +99,14 @@ extern int shearwater_profile_sample(void *handle, int columns, char **data, cha if (data[5]) cur_sample->cns = atoi(data[5]); if (data[6]) { - if (atoi(data[6]) > 0) { - cur_sample->stopdepth.mm = metric ? atoi(data[6]) * 1000 : feet_to_mm(atoi(data[6])); + d6 = atoi(data[6]); + if (d6 > 0) { + cur_sample->stopdepth.mm = metric ? d6 * 1000 : feet_to_mm(d6); cur_sample->in_deco = 1; } else if (data[7]) { - if (atoi(data[7]) > 0) { - cur_sample->stopdepth.mm = metric ? atoi(data[7]) * 1000 : feet_to_mm(atoi(data[7])); + d7 = atoi(data[7]); + if (d7 > 0) { + cur_sample->stopdepth.mm = metric ? d7 * 1000 : feet_to_mm(d7); if (data[8]) { cur_sample->stoptime.seconds = atoi(data[8]) * 60; } @@ -131,6 +134,7 @@ extern int shearwater_ai_profile_sample(void *handle, int columns, char **data, UNUSED(handle); UNUSED(columns); UNUSED(column); + int d6, d9; sample_start(); if (data[0]) @@ -147,12 +151,14 @@ extern int shearwater_ai_profile_sample(void *handle, int columns, char **data, if (data[5]) cur_sample->cns = atoi(data[5]); if (data[6]) { - if (atoi(data[6]) > 0) { - cur_sample->stopdepth.mm = metric ? atoi(data[6]) * 1000 : feet_to_mm(atoi(data[6])); + d6 = atoi(data[6]); + if (d6 > 0) { + cur_sample->stopdepth.mm = metric ? d6 * 1000 : feet_to_mm(d6); cur_sample->in_deco = 1; } else if (data[9]) { - if (atoi(data[9]) > 0) { - cur_sample->stopdepth.mm = metric ? atoi(data[9]) * 1000 : feet_to_mm(atoi(data[9])); + d9 = atoi(data[9]); + if (d9 > 0) { + cur_sample->stopdepth.mm = metric ? d9 * 1000 : feet_to_mm(d9); if (data[10]) { cur_sample->stoptime.seconds = atoi(data[10]) * 60; }