summaryrefslogtreecommitdiff
path: root/ext/dbm
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-07-18 07:44:17 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-07-18 07:44:17 (GMT)
commitf9c014d008e42eab79cffd6441147cbc95963cf5 (patch)
tree3afb5466189a595941b61933f0f98b2ded9c9530 /ext/dbm
parent5a03c2569046f9b3919429088f230b01e719360f (diff)
empty_p: optimize and warnings
* ext/dbm/dbm.c (fdbm_empty_p): not empty if first key exists. suppress warnngs by gcc 4.7 -Wstrict-overflow. * ext/sdbm/init.c (fsdbm_empty_p): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/dbm')
-rw-r--r--ext/dbm/dbm.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/ext/dbm/dbm.c b/ext/dbm/dbm.c
index 4bc1ce3..8f50e32 100644
--- a/ext/dbm/dbm.c
+++ b/ext/dbm/dbm.c
@@ -689,21 +689,20 @@ fdbm_empty_p(VALUE obj)
datum key;
struct dbmdata *dbmp;
DBM *dbm;
- int i = 0;
GetDBM2(obj, dbmp, dbm);
if (dbmp->di_size < 0) {
dbm = dbmp->di_dbm;
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
- i++;
+ return Qfalse;
}
}
else {
- i = (int)dbmp->di_size;
+ if (!dbmp->di_size)
+ return Qfalse;
}
- if (i == 0) return Qtrue;
- return Qfalse;
+ return Qtrue;
}
/*