diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-05-06 14:08:17 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-05-06 14:15:59 -0700 |
commit | 0c836ebc47cab2f37274ae03ab2be6c7b2fd0456 (patch) | |
tree | 2c55ca0c5aa1bb6e9dcb6cc8bb920cb28c75b5cd /equipment.c | |
parent | 024420a60ddf7d18a6bd2ce4aad30344be0edbac (diff) | |
download | subsurface-0c836ebc47cab2f37274ae03ab2be6c7b2fd0456.tar.gz |
Simplify string comparison
This is based on Linus' idea on the mailing list.
Treat NULL strings and empty strings as identical.
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'equipment.c')
-rw-r--r-- | equipment.c | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/equipment.c b/equipment.c index e63a876d0..548f15b5e 100644 --- a/equipment.c +++ b/equipment.c @@ -71,14 +71,6 @@ bool cylinder_none(void *_data) return cylinder_nodata(cyl) && cylinder_nosamples(cyl); } -/* descriptions are equal if they are both NULL or both non-NULL - and the same text */ -static bool description_equal(const char *desc1, const char *desc2) -{ - return ((!desc1 && !desc2) || - (desc1 && desc2 && strcmp(desc1, desc2) == 0)); -} - bool weightsystem_none(void *_data) { weightsystem_t *ws = _data; @@ -98,7 +90,7 @@ bool no_weightsystems(weightsystem_t *ws) static bool one_weightsystem_equal(weightsystem_t *ws1, weightsystem_t *ws2) { return ws1->weight.grams == ws2->weight.grams && - description_equal(ws1->description, ws2->description); + same_string(ws1->description, ws2->description); } bool weightsystems_equal(weightsystem_t *ws1, weightsystem_t *ws2) |