8300184: Optimize ResourceHashtableBase::iterate_all using _number_of_entries
Reviewed-by: dholmes, rehn
This commit is contained in:
parent
75b122feea
commit
0b9ff06f3a
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -228,12 +228,15 @@ class ResourceHashtableBase : public STORAGE {
|
||||
void iterate(Function function) const { // lambda enabled API
|
||||
Node* const* bucket = table();
|
||||
const unsigned sz = table_size();
|
||||
while (bucket < bucket_at(sz)) {
|
||||
int cnt = _number_of_entries;
|
||||
|
||||
while (cnt > 0 && bucket < bucket_at(sz)) {
|
||||
Node* node = *bucket;
|
||||
while (node != NULL) {
|
||||
bool cont = function(node->_key, node->_value);
|
||||
if (!cont) { return; }
|
||||
node = node->_next;
|
||||
--cnt;
|
||||
}
|
||||
++bucket;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user