mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8199781: Don't use naked == for comparing oops
Reviewed-by: coleenp, eosterlund, jrose
This commit is contained in:
parent
8b50176bdc
commit
b938ae51ce
36 changed files with 1484 additions and 1282 deletions
|
@ -26,6 +26,7 @@
|
|||
#define SHARE_VM_UTILITIES_GROWABLEARRAY_HPP
|
||||
|
||||
#include "memory/allocation.hpp"
|
||||
#include "oops/oop.hpp"
|
||||
#include "utilities/debug.hpp"
|
||||
#include "utilities/globalDefinitions.hpp"
|
||||
#include "utilities/ostream.hpp"
|
||||
|
@ -211,6 +212,15 @@ template<class E> class GrowableArray : public GenericGrowableArray {
|
|||
|
||||
void print();
|
||||
|
||||
inline static bool safe_equals(oop obj1, oop obj2) {
|
||||
return oopDesc::equals(obj1, obj2);
|
||||
}
|
||||
|
||||
template <class X>
|
||||
inline static bool safe_equals(X i1, X i2) {
|
||||
return i1 == i2;
|
||||
}
|
||||
|
||||
int append(const E& elem) {
|
||||
check_nesting();
|
||||
if (_len == _max) grow(_len);
|
||||
|
@ -295,7 +305,7 @@ template<class E> class GrowableArray : public GenericGrowableArray {
|
|||
|
||||
bool contains(const E& elem) const {
|
||||
for (int i = 0; i < _len; i++) {
|
||||
if (_data[i] == elem) return true;
|
||||
if (safe_equals(_data[i], elem)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue