fix: fixed performance issue in isEmptyObject() (#6484)

Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
Guillaume Masclet 2026-04-07 21:29:38 +02:00 committed by GitHub
parent 68f97f7588
commit 62610f69ad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -131,7 +131,15 @@ function isPlainObject(val) {
* @return {boolean} True if value is a empty Object, otherwise false
*/
function isEmptyObject(val) {
return val && Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
if (!isPlainObject(val)) {
return false;
}
for (var key in val) {
if (Object.prototype.hasOwnProperty.call(val, key)) {
return false;
}
}
return true;
}
/**