From: Linus Torvalds <[email protected]>
Date: Sun, 21 Feb 2016 15:15:25 -0800
Subject: [PATCH 2/4] pressure interpolation: simplify code

Getting rid of the pointless always-zero pressure now makes it obvious
how some of the remaining code can just be removed too: there is no
point in re-initializing the pressure_time entries to zero at the
segment start, because they started out zero and we just checked that we
don't do anything to them before we hit the segment start.

Similarly, now that the silly pressure testign is gone, it is obvious
that the code for "i < cur" and "i == curr" cases is identical, and the
two cases can just be collapsed.

Signed-off-by: Linus Torvalds <torvalds@ linux-foundation.org>
---

This is literally just removing two if-statements: the first one sets some 
fields to zero that we already know are zero, and the second one is 
collapsed with the if-statement next to it that has the same body.

 subsurface-core/gaspressures.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/subsurface-core/gaspressures.c b/subsurface-core/gaspressures.c
index 43c0a11cfb0d..c63e16204ea1 100644
--- a/subsurface-core/gaspressures.c
+++ b/subsurface-core/gaspressures.c
@@ -191,17 +191,7 @@ static struct pr_interpolate_struct 
get_pr_interpolate_data(pr_track_t *segment,
                        interpolate.pressure_time += entry->pressure_time;
                        break;
                }
-               if (entry->sec == segment->t_start) {
-                       interpolate.acc_pressure_time = 0;
-                       interpolate.pressure_time = 0;
-                       continue;
-               }
-               if (i < cur) {
-                       interpolate.acc_pressure_time += entry->pressure_time;
-                       interpolate.pressure_time += entry->pressure_time;
-                       continue;
-               }
-               if (i == cur) {
+               if (i <= cur) {
                        interpolate.acc_pressure_time += entry->pressure_time;
                        interpolate.pressure_time += entry->pressure_time;
                        continue;
-- 
2.7.0.170.ge572fef

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to