https://github.com/openjdk/jdk/blob/a4e5f08fefac50a1ced7ff4178d9d76f90797949/src/hotspot/share/classfile/stringTable.cpp#L610
The linear search is very slow. It should be replaced with a hashtable lookup.
class VerifyCompStrings : StackObj {
GrowableArray<oop>* _oops;
public:
size_t _errors;
VerifyCompStrings(GrowableArray<oop>* oops) : _oops(oops), _errors(0) {}
bool operator()(WeakHandle* val) {
oop s = val->resolve();
if (s == NULL) {
return true;
}
int len = _oops->length();
for (int i = 0; i < len; i++) {
bool eq = java_lang_String::equals(s, _oops->at(i));
assert(!eq, "Duplicate strings");
if (eq) {
_errors++;
}
}
_oops->push(s);
return true;
};
};
The linear search is very slow. It should be replaced with a hashtable lookup.
class VerifyCompStrings : StackObj {
GrowableArray<oop>* _oops;
public:
size_t _errors;
VerifyCompStrings(GrowableArray<oop>* oops) : _oops(oops), _errors(0) {}
bool operator()(WeakHandle* val) {
oop s = val->resolve();
if (s == NULL) {
return true;
}
int len = _oops->length();
for (int i = 0; i < len; i++) {
bool eq = java_lang_String::equals(s, _oops->at(i));
assert(!eq, "Duplicate strings");
if (eq) {
_errors++;
}
}
_oops->push(s);
return true;
};
};