Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace facebook::react {

constexpr int DEFAULT_MAX_SIZE = 1024;
constexpr size_t DEFAULT_MAX_SIZE = 1024;

/**
* A container for storing entries of type T, with the following properties:
Expand Down Expand Up @@ -47,7 +47,7 @@ class BoundedConsumableBuffer {
DROP = 2,
};

BoundedConsumableBuffer(int maxSize = DEFAULT_MAX_SIZE) : maxSize_(maxSize) {
BoundedConsumableBuffer(size_t maxSize = DEFAULT_MAX_SIZE) : maxSize_(maxSize) {
entries_.reserve(maxSize_);
}

Expand Down Expand Up @@ -229,18 +229,18 @@ class BoundedConsumableBuffer {
private:
std::vector<T> entries_;

const int maxSize_;
const size_t maxSize_;

// Current starting position in the circular buffer:
int position_{0};
size_t position_{0};

// Current "cursor" - positions of the firsst and after last unconsumed
// Current "cursor" - positions of the first and after last unconsumed
// element, relative to the starting position:
int cursorStart_{0};
int cursorEnd_{0};
size_t cursorStart_{0};
size_t cursorEnd_{0};

// Number of currently unconsumed elements:
int numToConsume_{0};
size_t numToConsume_{0};
};

} // namespace facebook::react
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace facebook::react {
namespace {

struct StrKey {
uint32_t key;
size_t key;
StrKey(std::string_view s) : key(std::hash<std::string_view>{}(s)) {}

bool operator==(const StrKey& rhs) const {
Expand All @@ -25,7 +25,7 @@ struct StrKey {

struct StrKeyHash {
constexpr size_t operator()(const StrKey& strKey) const {
return static_cast<size_t>(strKey.key);
return strKey.key;
}
};

Expand Down