diff options
author | Miika Turkia <miika.turkia@gmail.com> | 2018-05-27 16:56:09 +0300 |
---|---|---|
committer | Lubomir I. Ivanov <neolit123@gmail.com> | 2018-05-27 23:18:01 +0300 |
commit | a929c86584fadaa84ae6fce0f622ba4941e06e11 (patch) | |
tree | 098bf939da4d1a952b273ed03a5f6c9cc9bcb29b /core/import-shearwater.c | |
parent | bef573ae3f452be34d9c1e5464825596caa1ba81 (diff) | |
download | subsurface-a929c86584fadaa84ae6fce0f622ba4941e06e11.tar.gz |
Shearwater import: avoid running atoi multiple times
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Diffstat (limited to 'core/import-shearwater.c')
-rw-r--r-- | core/import-shearwater.c | 22 |
1 files 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; } |