Skip to content

src: use C++20 contains() method #59304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/inspector/io_agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ DispatchResponse IoAgent::read(const String& in_handle,
if (in_offset.has_value()) {
offset = *in_offset;
offset_was_specified = true;
} else if (offset_map_.find(url) != offset_map_.end()) {
} else if (offset_map_.contains(url)) {
offset = offset_map_[url];
}
int size = 1 << 20;
Expand Down
4 changes: 1 addition & 3 deletions src/inspector_profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ class V8ProfilerConnection {
simdjson::ondemand::object* result);
virtual void WriteProfile(simdjson::ondemand::object* result);

bool HasProfileId(uint64_t id) const {
return profile_ids_.find(id) != profile_ids_.end();
}
bool HasProfileId(uint64_t id) const { return profile_ids_.contains(id); }

void RemoveProfileId(uint64_t id) { profile_ids_.erase(id); }

Expand Down
4 changes: 2 additions & 2 deletions src/node_blob.cc
Original file line number Diff line number Diff line change
Expand Up @@ -537,11 +537,11 @@ void BlobBindingData::store_data_object(
}

void BlobBindingData::revoke_data_object(const std::string& uuid) {
if (data_objects_.find(uuid) == data_objects_.end()) {
if (!data_objects_.contains(uuid)) {
return;
}
data_objects_.erase(uuid);
CHECK_EQ(data_objects_.find(uuid), data_objects_.end());
CHECK(!data_objects_.contains(uuid));
}

BlobBindingData::StoredDataObject BlobBindingData::get_data_object(
Expand Down
2 changes: 1 addition & 1 deletion src/node_builtins.cc
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ MaybeLocal<Function> BuiltinLoader::LookupAndCompileInternal(
if (should_eager_compile_) {
options = ScriptCompiler::kEagerCompile;
} else if (!to_eager_compile_.empty()) {
if (to_eager_compile_.find(id) != to_eager_compile_.end()) {
if (to_eager_compile_.contains(id)) {
options = ScriptCompiler::kEagerCompile;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/node_env_var.cc
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ void MapKVStore::Set(Isolate* isolate, Local<String> key, Local<String> value) {

int32_t MapKVStore::Query(const char* key) const {
Mutex::ScopedLock lock(mutex_);
return map_.find(key) == map_.end() ? -1 : 0;
return map_.contains(key) ? 0 : -1;
}

int32_t MapKVStore::Query(Isolate* isolate, Local<String> key) const {
Expand Down
2 changes: 1 addition & 1 deletion src/node_messaging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,7 @@ Maybe<bool> SiblingGroup::Dispatch(
RwLock::ScopedReadLock lock(group_mutex_);

// The source MessagePortData is not part of this group.
if (ports_.find(source) == ports_.end()) {
if (!ports_.contains(source)) {
if (error != nullptr)
*error = "Source MessagePort is not entangled with this group.";
return Nothing<bool>();
Expand Down
2 changes: 1 addition & 1 deletion src/signal_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ void DecreaseSignalHandlerCount(int signum) {

bool HasSignalJSHandler(int signum) {
Mutex::ScopedLock lock(handled_signals_mutex);
return handled_signals.find(signum) != handled_signals.end();
return handled_signals.contains(signum);
}
} // namespace node

Expand Down
Loading