Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit c0aceed

Browse files
clarkezonecbracken
authored andcommitted
CR feedback
1 parent c53a1ca commit c0aceed

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

fml/unique_fd.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ struct UniqueFDTraits {
5050
static void RemoveCacheEntry(HANDLE fd) {
5151
const std::lock_guard<std::mutex> lock(file_map_mutex);
5252

53-
if (file_map.count(fd) > 0) {
54-
file_map.erase(fd);
55-
}
53+
file_map.erase(fd);
5654
}
5755

5856
static void StoreCacheEntry(HANDLE fd, DirCacheEntry state) {
@@ -62,10 +60,10 @@ struct UniqueFDTraits {
6260

6361
static std::optional<DirCacheEntry> GetCacheEntry(HANDLE fd) {
6462
const std::lock_guard<std::mutex> lock(file_map_mutex);
65-
if (file_map.count(fd) > 0) {
66-
return file_map[fd];
67-
}
68-
return {};
63+
auto found = file_map.find(fd);
64+
return found == file_map.end()
65+
? std::nullopt
66+
: std::optional<DirCacheEntry>{found->second};
6967
}
7068
};
7169

0 commit comments

Comments
 (0)