mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
5a03c25690
commit
f9c014d008
2 changed files with 8 additions and 10 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -714,21 +714,20 @@ fsdbm_empty_p(VALUE obj)
|
|||
datum key;
|
||||
struct dbmdata *dbmp;
|
||||
DBM *dbm;
|
||||
int i = 0;
|
||||
|
||||
GetDBM(obj, dbmp);
|
||||
if (dbmp->di_size < 0) {
|
||||
dbm = dbmp->di_dbm;
|
||||
|
||||
for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) {
|
||||
i++;
|
||||
return Qfalse;
|
||||
}
|
||||
}
|
||||
else {
|
||||
i = dbmp->di_size;
|
||||
if (!dbmp->di_size)
|
||||
return Qfalse;
|
||||
}
|
||||
if (i == 0) return Qtrue;
|
||||
return Qfalse;
|
||||
return Qtrue;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue