From c30e6dfbac45b6ef9b10ad0996161305dbc5f17d Mon Sep 17 00:00:00 2001 From: David Teller Date: Fri, 27 Sep 2019 10:48:00 +0000 Subject: [PATCH] Bug 1581875 - Improving documentation of XXXHuffmanTable::lookup;r=arai Differential Revision: https://phabricator.services.mozilla.com/D46952 --HG-- extra : moz-landing-system : lando --- js/src/frontend/BinASTTokenReaderContext.h | 54 +++++++++++++--------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/js/src/frontend/BinASTTokenReaderContext.h b/js/src/frontend/BinASTTokenReaderContext.h index 696c08b24db9..b110f7fd9236 100644 --- a/js/src/frontend/BinASTTokenReaderContext.h +++ b/js/src/frontend/BinASTTokenReaderContext.h @@ -236,13 +236,16 @@ class NaiveHuffmanTable { // Lookup a value in the table. // - // Return an entry with a value of `nullptr` if the value is not in the table. + // The return of this method contains: // - // The lookup may advance `key` by `[0, key.bitLength]` bits. Typically, in a - // table with a single instance, or if the value is not in the table, it - // will advance by 0 bits. The caller is responsible for advancing its - // bitstream by `result.key.bitLength` bits. - HuffmanEntry lookup(HuffmanLookup key) const; + // - the resulting value (`nullptr` if the value is not in the table); + // - the number of bits in the entry associated to this value. + // + // Note that entries inside a single table are typically associated to + // distinct bit lengths. The caller is responsible for checking + // the result of this method and advancing the bitstream by + // `result.key.bitLength` bits. + HuffmanEntry lookup(HuffmanLookup lookup) const; // The number of values in the table. size_t length() const { return values.length(); } @@ -459,12 +462,15 @@ class SingleLookupHuffmanTable { // Lookup a value in the table. // - // Return an entry with a value of `nullptr` if the value is not in the table. + // The return of this method contains: // - // The lookup may advance `key` by `[0, key.bitLength]` bits. Typically, in a - // table with a single instance, or if the value is not in the table, it - // will advance by 0 bits. The caller is responsible for advancing its - // bitstream by `result.key.bitLength` bits. + // - the resulting value (`nullptr` if the value is not in the table); + // - the number of bits in the entry associated to this value. + // + // Note that entries inside a single table are typically associated to + // distinct bit lengths. The caller is responsible for checking + // the result of this method and advancing the bitstream by + // `result.key.bitLength` bits. HuffmanEntry lookup(HuffmanLookup key) const; // The number of values in the table. @@ -654,12 +660,15 @@ class MultiLookupHuffmanTable { // Lookup a value in the table. // - // Return an entry with a value of `nullptr` if the value is not in the table. + // The return of this method contains: // - // The lookup may advance `key` by `[0, key.bitLength]` bits. Typically, in a - // table with a single instance, or if the value is not in the table, it - // will advance by 0 bits. The caller is responsible for advancing its - // bitstream by `result.key.bitLength` bits. + // - the resulting value (`nullptr` if the value is not in the table); + // - the number of bits in the entry associated to this value. + // + // Note that entries inside a single table are typically associated to + // distinct bit lengths. The caller is responsible for checking + // the result of this method and advancing the bitstream by + // `result.key.bitLength` bits. HuffmanEntry lookup(HuffmanLookup key) const; // The number of values in the table. @@ -786,12 +795,15 @@ struct GenericHuffmanTable { // Lookup a value in the table. // - // Return an entry with a value of `nullptr` if the value is not in the table. + // The return of this method contains: // - // The lookup may advance `key` by `[0, key.bitLength]` bits. Typically, in a - // table with a single instance, or if the value is not in the table, it - // will advance by 0 bits. The caller is responsible for advancing its - // bitstream by `result.key.bitLength` bits. + // - the resulting value (`nullptr` if the value is not in the table); + // - the number of bits in the entry associated to this value. + // + // Note that entries inside a single table are typically associated to + // distinct bit lengths. The caller is responsible for checking + // the result of this method and advancing the bitstream by + // `result.key.bitLength` bits. HuffmanEntry lookup(HuffmanLookup key) const; private: