| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b3372a8 commit 0c7e69a
9 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -247,7 +247,7 @@ size_t BlobSerializer<Impl>::WriteVector(const std::vector<T>& data) { | |||
| 247 | 247 | } | |
| 248 | 248 | ||
| 249 | 249 | size_t written_total = WriteArithmetic<size_t>(data.size()); | |
| 250 | - if (data.size() == 0) { | ||
| 250 | + if (data.empty()) { | ||
| 251 | 251 | return written_total; | |
| 252 | 252 | } | |
| 253 | 253 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -134,7 +134,7 @@ WebCryptoCipherStatus AES_Cipher( | |||
| 134 | 134 | // | |
| 135 | 135 | // Refs: https://github.com/openssl/openssl/commit/420cb707b880e4fb649094241371701013eeb15f | |
| 136 | 136 | // Refs: https://github.com/nodejs/node/pull/38913#issuecomment-866505244 | |
| 137 | - if (in.size() == 0) { | ||
| 137 | + if (in.empty()) { | ||
| 138 | 138 | out_len = 0; | |
| 139 | 139 | } else if (!EVP_CipherUpdate(ctx.get(), | |
| 140 | 140 | buf.data<unsigned char>(), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -398,8 +398,7 @@ void ECDH::ConvertKey(const FunctionCallbackInfo<Value>& args) { | |||
| 398 | 398 | ArrayBufferOrViewContents<char> args0(args[0]); | |
| 399 | 399 | if (UNLIKELY(!args0.CheckSizeInt32())) | |
| 400 | 400 | return THROW_ERR_OUT_OF_RANGE(env, "key is too big"); | |
| 401 | - if (args0.size() == 0) | ||
| 402 | - return args.GetReturnValue().SetEmptyString(); | ||
| 401 | + if (args0.empty()) return args.GetReturnValue().SetEmptyString(); | ||
| 403 | 402 | ||
| 404 | 403 | node::Utf8Value curve(env->isolate(), args[1]); | |
| 405 | 404 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -39,8 +39,7 @@ bool VerifySpkac(const ArrayBufferOrViewContents<char>& input) { | |||
| 39 | 39 | void VerifySpkac(const FunctionCallbackInfo<Value>& args) { | |
| 40 | 40 | Environment* env = Environment::GetCurrent(args); | |
| 41 | 41 | ArrayBufferOrViewContents<char> input(args[0]); | |
| 42 | - if (input.size() == 0) | ||
| 43 | - return args.GetReturnValue().SetEmptyString(); | ||
| 42 | + if (input.empty()) return args.GetReturnValue().SetEmptyString(); | ||
| 44 | 43 | ||
| 45 | 44 | if (UNLIKELY(!input.CheckSizeInt32())) | |
| 46 | 45 | return THROW_ERR_OUT_OF_RANGE(env, "spkac is too large"); | |
@@ -76,7 +75,7 @@ void ExportPublicKey(const FunctionCallbackInfo<Value>& args) { | |||
| 76 | 75 | Environment* env = Environment::GetCurrent(args); | |
| 77 | 76 | ||
| 78 | 77 | ArrayBufferOrViewContents<char> input(args[0]); | |
| 79 | - if (input.size() == 0) return args.GetReturnValue().SetEmptyString(); | ||
| 78 | + if (input.empty()) return args.GetReturnValue().SetEmptyString(); | ||
| 80 | 79 | ||
| 81 | 80 | if (UNLIKELY(!input.CheckSizeInt32())) | |
| 82 | 81 | return THROW_ERR_OUT_OF_RANGE(env, "spkac is too large"); | |
@@ -109,8 +108,7 @@ void ExportChallenge(const FunctionCallbackInfo<Value>& args) { | |||
| 109 | 108 | Environment* env = Environment::GetCurrent(args); | |
| 110 | 109 | ||
| 111 | 110 | ArrayBufferOrViewContents<char> input(args[0]); | |
| 112 | - if (input.size() == 0) | ||
| 113 | - return args.GetReturnValue().SetEmptyString(); | ||
| 111 | + if (input.empty()) return args.GetReturnValue().SetEmptyString(); | ||
| 114 | 112 | ||
| 115 | 113 | if (UNLIKELY(!input.CheckSizeInt32())) | |
| 116 | 114 | return THROW_ERR_OUT_OF_RANGE(env, "spkac is too large"); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -233,6 +233,9 @@ class ByteSource { | |||
| 233 | 233 | // Returns the (allocated) size in bytes. | |
| 234 | 234 | size_t size() const { return size_; } | |
| 235 | 235 | ||
| 236 | + // Returns if (allocated) size is zero. | ||
| 237 | + bool empty() const { return size_ == 0; } | ||
| 238 | + | ||
| 236 | 239 | // Finalizes the Builder and returns a read-only view that is optionally | |
| 237 | 240 | // truncated. | |
| 238 | 241 | ByteSource release(std::optional<size_t> resize = std::nullopt) && { | |
@@ -271,6 +274,8 @@ class ByteSource { | |||
| 271 | 274 | ||
| 272 | 275 | size_t size() const { return size_; } | |
| 273 | 276 | ||
| 277 | + bool empty() const { return size_ == 0; } | ||
| 278 | + | ||
| 274 | 279 | operator bool() const { return data_ != nullptr; } | |
| 275 | 280 | ||
| 276 | 281 | BignumPointer ToBN() const { | |
@@ -718,22 +723,22 @@ class ArrayBufferOrViewContents { | |||
| 718 | 723 | // Ideally, these would return nullptr if IsEmpty() or length_ is zero, | |
| 719 | 724 | // but some of the openssl API react badly if given a nullptr even when | |
| 720 | 725 | // length is zero, so we have to return something. | |
| 721 | - if (size() == 0) | ||
| 722 | - return &buf; | ||
| 726 | + if (empty()) return &buf; | ||
| 723 | 727 | return reinterpret_cast<T*>(data_) + offset_; | |
| 724 | 728 | } | |
| 725 | 729 | ||
| 726 | 730 | inline T* data() { | |
| 727 | 731 | // Ideally, these would return nullptr if IsEmpty() or length_ is zero, | |
| 728 | 732 | // but some of the openssl API react badly if given a nullptr even when | |
| 729 | 733 | // length is zero, so we have to return something. | |
| 730 | - if (size() == 0) | ||
| 731 | - return &buf; | ||
| 734 | + if (empty()) return &buf; | ||
| 732 | 735 | return reinterpret_cast<T*>(data_) + offset_; | |
| 733 | 736 | } | |
| 734 | 737 | ||
| 735 | 738 | inline size_t size() const { return length_; } | |
| 736 | 739 | ||
| 740 | + inline bool empty() const { return length_ == 0; } | ||
| 741 | + | ||
| 737 | 742 | // In most cases, input buffer sizes passed in to openssl need to | |
| 738 | 743 | // be limited to <= INT_MAX. This utility method helps us check. | |
| 739 | 744 | inline bool CheckSizeInt32() { return size() <= INT_MAX; } | |
@@ -743,14 +748,14 @@ class ArrayBufferOrViewContents { | |||
| 743 | 748 | } | |
| 744 | 749 | ||
| 745 | 750 | inline ByteSource ToCopy() const { | |
| 746 | - if (size() == 0) return ByteSource(); | ||
| 751 | + if (empty()) return ByteSource(); | ||
| 747 | 752 | ByteSource::Builder buf(size()); | |
| 748 | 753 | memcpy(buf.data<void>(), data(), size()); | |
| 749 | 754 | return std::move(buf).release(); | |
| 750 | 755 | } | |
| 751 | 756 | ||
| 752 | 757 | inline ByteSource ToNullTerminatedCopy() const { | |
| 753 | - if (size() == 0) return ByteSource(); | ||
| 758 | + if (empty()) return ByteSource(); | ||
| 754 | 759 | ByteSource::Builder buf(size() + 1); | |
| 755 | 760 | memcpy(buf.data<void>(), data(), size()); | |
| 756 | 761 | buf.data<char>()[size()] = 0; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -125,7 +125,7 @@ v8::Maybe<bool> ModuleWrap::CheckUnsettledTopLevelAwait() { | |||
| 125 | 125 | ||
| 126 | 126 | auto stalled_messages = | |
| 127 | 127 | std::get<1>(module->GetStalledTopLevelAwaitMessages(isolate)); | |
| 128 | - if (stalled_messages.size() == 0) { | ||
| 128 | + if (stalled_messages.empty()) { | ||
| 129 | 129 | return v8::Just(true); | |
| 130 | 130 | } | |
| 131 | 131 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1580,7 +1580,7 @@ int MKDirpSync(uv_loop_t* loop, | |||
| 1580 | 1580 | // ~FSReqWrapSync(): | |
| 1581 | 1581 | case 0: | |
| 1582 | 1582 | req_wrap->continuation_data()->MaybeSetFirstPath(next_path); | |
| 1583 | - if (req_wrap->continuation_data()->paths().size() == 0) { | ||
| 1583 | + if (req_wrap->continuation_data()->paths().empty()) { | ||
| 1584 | 1584 | return 0; | |
| 1585 | 1585 | } | |
| 1586 | 1586 | break; | |
@@ -1596,7 +1596,7 @@ int MKDirpSync(uv_loop_t* loop, | |||
| 1596 | 1596 | if (dirname != next_path) { | |
| 1597 | 1597 | req_wrap->continuation_data()->PushPath(std::move(next_path)); | |
| 1598 | 1598 | req_wrap->continuation_data()->PushPath(std::move(dirname)); | |
| 1599 | - } else if (req_wrap->continuation_data()->paths().size() == 0) { | ||
| 1599 | + } else if (req_wrap->continuation_data()->paths().empty()) { | ||
| 1600 | 1600 | err = UV_EEXIST; | |
| 1601 | 1601 | continue; | |
| 1602 | 1602 | } | |
@@ -1653,7 +1653,7 @@ int MKDirpAsync(uv_loop_t* loop, | |||
| 1653 | 1653 | // Note: uv_fs_req_cleanup in terminal paths will be called by | |
| 1654 | 1654 | // FSReqAfterScope::~FSReqAfterScope() | |
| 1655 | 1655 | case 0: { | |
| 1656 | - if (req_wrap->continuation_data()->paths().size() == 0) { | ||
| 1656 | + if (req_wrap->continuation_data()->paths().empty()) { | ||
| 1657 | 1657 | req_wrap->continuation_data()->MaybeSetFirstPath(path); | |
| 1658 | 1658 | req_wrap->continuation_data()->Done(0); | |
| 1659 | 1659 | } else { | |
@@ -1676,7 +1676,7 @@ int MKDirpAsync(uv_loop_t* loop, | |||
| 1676 | 1676 | if (dirname != path) { | |
| 1677 | 1677 | req_wrap->continuation_data()->PushPath(path); | |
| 1678 | 1678 | req_wrap->continuation_data()->PushPath(std::move(dirname)); | |
| 1679 | - } else if (req_wrap->continuation_data()->paths().size() == 0) { | ||
| 1679 | + } else if (req_wrap->continuation_data()->paths().empty()) { | ||
| 1680 | 1680 | err = UV_EEXIST; | |
| 1681 | 1681 | continue; | |
| 1682 | 1682 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -177,7 +177,7 @@ FSPermission::RadixTree::~RadixTree() { | |||
| 177 | 177 | bool FSPermission::RadixTree::Lookup(const std::string_view& s, | |
| 178 | 178 | bool when_empty_return) const { | |
| 179 | 179 | FSPermission::RadixTree::Node* current_node = root_node_; | |
| 180 | - if (current_node->children.size() == 0) { | ||
| 180 | + if (current_node->children.empty()) { | ||
| 181 | 181 | return when_empty_return; | |
| 182 | 182 | } | |
| 183 | 183 | size_t parent_node_prefix_len = current_node->prefix.length(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -129,7 +129,7 @@ class FSPermission final : public PermissionBase { | |||
| 129 | 129 | // ---> er | |
| 130 | 130 | // ---> n | |
| 131 | 131 | bool IsEndNode() const { | |
| 132 | - if (children.size() == 0) { | ||
| 132 | + if (children.empty()) { | ||
| 133 | 133 | return true; | |
| 134 | 134 | } | |
| 135 | 135 | return is_leaf; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments