From 85b6f0a442bb1143f004bd851efe707336c62eb8 Mon Sep 17 00:00:00 2001 From: David Teller Date: Fri, 13 Sep 2019 08:49:02 +0000 Subject: [PATCH] Bug 1579862 - Making single-arg constructors explicit;r=arai Differential Revision: https://phabricator.services.mozilla.com/D45813 --HG-- extra : moz-landing-system : lando --- js/src/frontend/BinASTTokenReaderContext.cpp | 10 +++++----- js/src/frontend/BinASTTokenReaderContext.h | 15 +++++++++------ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/js/src/frontend/BinASTTokenReaderContext.cpp b/js/src/frontend/BinASTTokenReaderContext.cpp index 5932e68d70bb..8ab6a65b5c83 100644 --- a/js/src/frontend/BinASTTokenReaderContext.cpp +++ b/js/src/frontend/BinASTTokenReaderContext.cpp @@ -1734,11 +1734,11 @@ HuffmanTableImplementationGeneric::begin() const { return this->implementation.match( [](const HuffmanTableImplementationSaturated& implementation) -> HuffmanTableImplementationGeneric::Iterator { - return implementation.begin(); + return Iterator(implementation.begin()); }, [](const HuffmanTableImplementationMap& implementation) -> HuffmanTableImplementationGeneric::Iterator { - return implementation.begin(); + return Iterator(implementation.begin()); }, [](const HuffmanTableUnreachable&) -> HuffmanTableImplementationGeneric::Iterator { @@ -1752,11 +1752,11 @@ HuffmanTableImplementationGeneric::end() const { return this->implementation.match( [](const HuffmanTableImplementationSaturated& implementation) -> HuffmanTableImplementationGeneric::Iterator { - return implementation.end(); + return Iterator(implementation.end()); }, [](const HuffmanTableImplementationMap& implementation) -> HuffmanTableImplementationGeneric::Iterator { - return implementation.end(); + return Iterator(implementation.end()); }, [](const HuffmanTableUnreachable&) -> HuffmanTableImplementationGeneric::Iterator { @@ -1964,7 +1964,7 @@ HuffmanEntry HuffmanTableImplementationMap::lookup( const uint32_t bits = lookup.leadingBits(bitLength); const HuffmanKey key(bits, bitLength); const FlatHuffmanKey flat(key); - if (auto ptr = values.lookup(key)) { + if (auto ptr = values.lookup(flat)) { // Entry found. return HuffmanEntry(bits, bitLength, &ptr->value()); } diff --git a/js/src/frontend/BinASTTokenReaderContext.h b/js/src/frontend/BinASTTokenReaderContext.h index 77dc8613b364..af805da65db5 100644 --- a/js/src/frontend/BinASTTokenReaderContext.h +++ b/js/src/frontend/BinASTTokenReaderContext.h @@ -130,8 +130,8 @@ struct HuffmanKey { // A Huffman key represented as a single `uint32_t`. struct FlatHuffmanKey { - FlatHuffmanKey(HuffmanKey key); - FlatHuffmanKey(const HuffmanKey* key); + explicit FlatHuffmanKey(HuffmanKey key); + explicit FlatHuffmanKey(const HuffmanKey* key); // 0b0000000L_LLLLCCCC_CCCCCCCC_CCCCCCCC // Where: @@ -489,8 +489,8 @@ struct HuffmanTableUnreachable {}; // template struct HuffmanTableImplementationGeneric { - HuffmanTableImplementationGeneric(JSContext* cx); - HuffmanTableImplementationGeneric() = delete; + explicit HuffmanTableImplementationGeneric(JSContext* cx); + explicit HuffmanTableImplementationGeneric() = delete; // Initialize a Huffman table containing a single value. JS::Result initWithSingleValue(JSContext* cx, T&& value); @@ -511,8 +511,11 @@ struct HuffmanTableImplementationGeneric { size_t length() const; struct Iterator { - Iterator(typename HuffmanTableImplementationSaturated::Iterator&&); - Iterator(typename HuffmanTableImplementationMap::Iterator&&); + explicit Iterator( + typename HuffmanTableImplementationSaturated::Iterator&&); + explicit Iterator(typename HuffmanTableImplementationMap::Iterator&&); + Iterator(Iterator&&) = default; + Iterator(const Iterator&) = default; void operator++(); const T* operator*() const; bool operator==(const Iterator& other) const;