diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2013-11-16 19:21:54 -0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-11-16 20:27:54 -0800 |
commit | 314cf4c628ac6e709de93f18be384fe819b46f81 (patch) | |
tree | 2797068c52f47caaa1b1f5b1d1bdfdd8e2dca70b /divelist.c | |
parent | ad0aa8cc497fb954b3fd08aa603d24c384fd16de (diff) | |
download | subsurface-314cf4c628ac6e709de93f18be384fe819b46f81.tar.gz |
Removed duplicated method.
This patch removes a duplicated method: get_divenr and
get_index_for_dive. The two are exactly the same ( if my
c is not broken, but I may be broken since I'm working like
crazy for almost 30h nonstop. ), so please take a good look
before applying this one.
[Dirk Hohndel: Tomaz took the slightly broken of the two implementations,
so I switched that out for the correct one]
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'divelist.c')
-rw-r--r-- | divelist.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/divelist.c b/divelist.c index 28d082029..9a1ab017f 100644 --- a/divelist.c +++ b/divelist.c @@ -368,10 +368,12 @@ static void add_dive_to_deco(struct dive *dive) int get_divenr(struct dive *dive) { - int divenr = -1; - while (++divenr < dive_table.nr && get_dive(divenr) != dive) - ; - return divenr; + int i; + struct dive *d; + for_each_dive(i, d) + if (d == dive) + return i; + return -1; } static struct gasmix air = { .o2.permille = O2_IN_AIR }; @@ -787,8 +789,8 @@ struct dive *merge_two_dives(struct dive *a, struct dive *b) if (!a || !b) return NULL; - i = get_index_for_dive(a); - j = get_index_for_dive(b); + i = get_divenr(a); + j = get_divenr(b); res = merge_dives(a, b, b->when - a->when, FALSE); if (!res) return NULL; |