From patchwork Wed Nov 20 21:14:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Fran=C3=A7ois_Dumont?= X-Patchwork-Id: 292870 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9250E2C008F for ; Thu, 21 Nov 2013 08:15:37 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=g8wiUKYTxuzg+91jugAGZQPTVhH5WvXTHnpT+L7055q869 URm8QsvmCL3Jy7xTSauFoEukCQJUVHQX/jzDvmkTFhjI58WsPcu6ITAyuhra0knI Ua1rCB1vhVp84IE8i4LHCHZ/j6rRbHLaJy7EpeOONTKEou/YEQAscqiLSF3v8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=KBorOi9ykFyUGSr0iWDnijSyIWo=; b=LAkqKaHnGt9mv3sj/de/ /LGZlALl90svwnHqSSvOR2YTry3YMSwJRlgVykejJNMmb/gw6iFgfS3lj87ciNvu ai44+MKL5pogtHYIiFObksM+nqRKyQCmk809T0og7iBtLJVNCP+qSrOsVAEfvU7F 9l1+5OagqBLuN8iYgWjD6hA= Received: (qmail 28286 invoked by alias); 20 Nov 2013 21:14:59 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 28254 invoked by uid 89); 20 Nov 2013 21:14:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.6 required=5.0 tests=AWL, BAYES_50, FREEMAIL_FROM, RDNS_NONE, SPF_PASS, URIBL_BLOCKED autolearn=no version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-we0-f172.google.com Received: from Unknown (HELO mail-we0-f172.google.com) (74.125.82.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 20 Nov 2013 21:14:32 +0000 Received: by mail-we0-f172.google.com with SMTP id t60so4867146wes.31 for ; Wed, 20 Nov 2013 13:14:22 -0800 (PST) X-Received: by 10.180.94.100 with SMTP id db4mr27298339wib.14.1384982062582; Wed, 20 Nov 2013 13:14:22 -0800 (PST) Received: from localhost.localdomain (arf62-1-82-237-250-248.fbx.proxad.net. [82.237.250.248]) by mx.google.com with ESMTPSA id r4sm19979786wib.6.2013.11.20.13.14.20 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 20 Nov 2013 13:14:21 -0800 (PST) Message-ID: <528D262B.2050407@gmail.com> Date: Wed, 20 Nov 2013 22:14:19 +0100 From: =?ISO-8859-1?Q?Fran=E7ois_Dumont?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120829 Thunderbird/15.0 MIME-Version: 1.0 To: "libstdc++@gcc.gnu.org" , gcc-patches Subject: Remove debug local iterator bucket information Hi At the time of writing unordered container debug mode, local iterator didn't have the bucket information. Now they have so I would like debug mode to use it rather than duplicating the information. 2013-11-21 François Dumont * include/debug/safe_local_iterator.h (_Safe_local_iterator<>): Remove _M_bucket, use same information in normal local_iterator. * include/debug/safe_local_iterator.tcc: Adapt. * include/debug/unordered_set: Likewise. * include/debug/unordered_map: Likewise. Tested under Linux x86_64. Ok to commit ? François Index: include/debug/safe_local_iterator.h =================================================================== --- include/debug/safe_local_iterator.h (revision 205141) +++ include/debug/safe_local_iterator.h (working copy) @@ -58,9 +58,6 @@ /// The underlying iterator _Iterator _M_current; - /// The bucket this local iterator belongs to - size_type _M_bucket; - /// Determine if this is a constant iterator. bool _M_constant() const @@ -89,10 +86,8 @@ * @pre @p seq is not NULL * @post this is not singular */ - _Safe_local_iterator(const _Iterator& __i, size_type __bucket, - const _Sequence* __seq) - : _Safe_local_iterator_base(__seq, _M_constant()), _M_current(__i), - _M_bucket(__bucket) + _Safe_local_iterator(const _Iterator& __i, const _Sequence* __seq) + : _Safe_local_iterator_base(__seq, _M_constant()), _M_current(__i) { _GLIBCXX_DEBUG_VERIFY(!this->_M_singular(), _M_message(__msg_init_singular) @@ -104,12 +99,12 @@ */ _Safe_local_iterator(const _Safe_local_iterator& __x) : _Safe_local_iterator_base(__x, _M_constant()), - _M_current(__x._M_current), _M_bucket(__x._M_bucket) + _M_current(__x._M_current) { // _GLIBCXX_RESOLVE_LIB_DEFECTS // DR 408. Is vector > forbidden? _GLIBCXX_DEBUG_VERIFY(!__x._M_singular() - || __x._M_current == _Iterator(), + || __x.base() == _Iterator(), _M_message(__msg_init_copy_singular) ._M_iterator(*this, "this") ._M_iterator(__x, "other")); @@ -127,7 +122,7 @@ typename _Sequence::local_iterator::iterator_type>::__value, _Sequence>::__type>& __x) : _Safe_local_iterator_base(__x, _M_constant()), - _M_current(__x.base()), _M_bucket(__x._M_bucket) + _M_current(__x.base()) { // _GLIBCXX_RESOLVE_LIB_DEFECTS // DR 408. Is vector > forbidden? @@ -147,12 +142,11 @@ // _GLIBCXX_RESOLVE_LIB_DEFECTS // DR 408. Is vector > forbidden? _GLIBCXX_DEBUG_VERIFY(!__x._M_singular() - || __x._M_current == _Iterator(), + || __x.base() == _Iterator(), _M_message(__msg_copy_singular) ._M_iterator(*this, "this") ._M_iterator(__x, "other")); _M_current = __x._M_current; - _M_bucket = __x._M_bucket; this->_M_attach(__x._M_sequence); return *this; } @@ -225,7 +219,7 @@ * @brief Return the bucket */ size_type - bucket() const { return _M_bucket; } + bucket() const { return _M_current._M_bucket; } /** * @brief Conversion to underlying non-debug iterator to allow @@ -266,19 +260,20 @@ _M_get_sequence() const { return static_cast<_Sequence*>(_M_sequence); } - /// Is this iterator equal to the sequence's begin() iterator? + /// Is this iterator equal to the sequence's begin(bucket) iterator? bool _M_is_begin() const - { return base() == _M_get_sequence()->_M_base().begin(_M_bucket); } + { return base() == _M_get_sequence()->_M_base().begin(bucket()); } - /// Is this iterator equal to the sequence's end() iterator? + /// Is this iterator equal to the sequence's end(bucket) iterator? bool _M_is_end() const - { return base() == _M_get_sequence()->_M_base().end(_M_bucket); } + { return base() == _M_get_sequence()->_M_base().end(bucket()); } /// Is this iterator part of the same bucket as the other one? - template - bool _M_in_same_bucket(const _Safe_local_iterator<_Other, - _Sequence>& __other) const - { return _M_bucket == __other.bucket(); } + template + bool + _M_in_same_bucket(const _Safe_local_iterator<_Other, + _Sequence>& __other) const + { return bucket() == __other.bucket(); } }; template @@ -286,7 +281,7 @@ operator==(const _Safe_local_iterator<_IteratorL, _Sequence>& __lhs, const _Safe_local_iterator<_IteratorR, _Sequence>& __rhs) { - _GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(), + _GLIBCXX_DEBUG_VERIFY(!__lhs._M_singular() && !__rhs._M_singular(), _M_message(__msg_iter_compare_bad) ._M_iterator(__lhs, "lhs") ._M_iterator(__rhs, "rhs")); @@ -294,10 +289,6 @@ _M_message(__msg_compare_different) ._M_iterator(__lhs, "lhs") ._M_iterator(__rhs, "rhs")); - _GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs), - _M_message(__msg_compare_different) - ._M_iterator(__lhs, "lhs") - ._M_iterator(__rhs, "rhs")); _GLIBCXX_DEBUG_VERIFY(__lhs._M_in_same_bucket(__rhs), _M_message(__msg_local_iter_compare_bad) ._M_iterator(__lhs, "lhs") @@ -310,7 +301,7 @@ operator==(const _Safe_local_iterator<_Iterator, _Sequence>& __lhs, const _Safe_local_iterator<_Iterator, _Sequence>& __rhs) { - _GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(), + _GLIBCXX_DEBUG_VERIFY(!__lhs._M_singular() && !__rhs._M_singular(), _M_message(__msg_iter_compare_bad) ._M_iterator(__lhs, "lhs") ._M_iterator(__rhs, "rhs")); @@ -350,7 +341,7 @@ operator!=(const _Safe_local_iterator<_Iterator, _Sequence>& __lhs, const _Safe_local_iterator<_Iterator, _Sequence>& __rhs) { - _GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(), + _GLIBCXX_DEBUG_VERIFY(!__lhs._M_singular() && !__rhs._M_singular(), _M_message(__msg_iter_compare_bad) ._M_iterator(__lhs, "lhs") ._M_iterator(__rhs, "rhs")); Index: include/debug/safe_local_iterator.tcc =================================================================== --- include/debug/safe_local_iterator.tcc (revision 205141) +++ include/debug/safe_local_iterator.tcc (working copy) @@ -38,7 +38,7 @@ { if (!_M_can_compare(__rhs)) return false; - if (_M_bucket != __rhs._M_bucket) + if (bucket() != __rhs.bucket()) return false; /* Determine if we can order the iterators without the help of Index: include/debug/unordered_set =================================================================== --- include/debug/unordered_set (revision 205141) +++ include/debug/unordered_set (working copy) @@ -207,42 +207,42 @@ begin(size_type __b) { __glibcxx_check_bucket_index(__b); - return local_iterator(_Base::begin(__b), __b, this); + return local_iterator(_Base::begin(__b), this); } local_iterator end(size_type __b) { __glibcxx_check_bucket_index(__b); - return local_iterator(_Base::end(__b), __b, this); + return local_iterator(_Base::end(__b), this); } const_local_iterator begin(size_type __b) const { __glibcxx_check_bucket_index(__b); - return const_local_iterator(_Base::begin(__b), __b, this); + return const_local_iterator(_Base::begin(__b), this); } const_local_iterator end(size_type __b) const { __glibcxx_check_bucket_index(__b); - return const_local_iterator(_Base::end(__b), __b, this); + return const_local_iterator(_Base::end(__b), this); } const_local_iterator cbegin(size_type __b) const { __glibcxx_check_bucket_index(__b); - return const_local_iterator(_Base::cbegin(__b), __b, this); + return const_local_iterator(_Base::cbegin(__b), this); } const_local_iterator cend(size_type __b) const { __glibcxx_check_bucket_index(__b); - return const_local_iterator(_Base::cend(__b), __b, this); + return const_local_iterator(_Base::cend(__b), this); } size_type @@ -658,42 +658,42 @@ begin(size_type __b) { __glibcxx_check_bucket_index(__b); - return local_iterator(_Base::begin(__b), __b, this); + return local_iterator(_Base::begin(__b), this); } local_iterator end(size_type __b) { __glibcxx_check_bucket_index(__b); - return local_iterator(_Base::end(__b), __b, this); + return local_iterator(_Base::end(__b), this); } const_local_iterator begin(size_type __b) const { __glibcxx_check_bucket_index(__b); - return const_local_iterator(_Base::begin(__b), __b, this); + return const_local_iterator(_Base::begin(__b), this); } const_local_iterator end(size_type __b) const { __glibcxx_check_bucket_index(__b); - return const_local_iterator(_Base::end(__b), __b, this); + return const_local_iterator(_Base::end(__b), this); } const_local_iterator cbegin(size_type __b) const { __glibcxx_check_bucket_index(__b); - return const_local_iterator(_Base::cbegin(__b), __b, this); + return const_local_iterator(_Base::cbegin(__b), this); } const_local_iterator cend(size_type __b) const { __glibcxx_check_bucket_index(__b); - return const_local_iterator(_Base::cend(__b), __b, this); + return const_local_iterator(_Base::cend(__b), this); } size_type Index: include/debug/unordered_map =================================================================== --- include/debug/unordered_map (revision 205141) +++ include/debug/unordered_map (working copy) @@ -208,42 +208,42 @@ begin(size_type __b) { __glibcxx_check_bucket_index(__b); - return local_iterator(_Base::begin(__b), __b, this); + return local_iterator(_Base::begin(__b), this); } local_iterator end(size_type __b) { __glibcxx_check_bucket_index(__b); - return local_iterator(_Base::end(__b), __b, this); + return local_iterator(_Base::end(__b), this); } const_local_iterator begin(size_type __b) const { __glibcxx_check_bucket_index(__b); - return const_local_iterator(_Base::begin(__b), __b, this); + return const_local_iterator(_Base::begin(__b), this); } const_local_iterator end(size_type __b) const { __glibcxx_check_bucket_index(__b); - return const_local_iterator(_Base::end(__b), __b, this); + return const_local_iterator(_Base::end(__b), this); } const_local_iterator cbegin(size_type __b) const { __glibcxx_check_bucket_index(__b); - return const_local_iterator(_Base::cbegin(__b), __b, this); + return const_local_iterator(_Base::cbegin(__b), this); } const_local_iterator cend(size_type __b) const { __glibcxx_check_bucket_index(__b); - return const_local_iterator(_Base::cend(__b), __b, this); + return const_local_iterator(_Base::cend(__b), this); } size_type @@ -664,42 +664,42 @@ begin(size_type __b) { __glibcxx_check_bucket_index(__b); - return local_iterator(_Base::begin(__b), __b, this); + return local_iterator(_Base::begin(__b), this); } local_iterator end(size_type __b) { __glibcxx_check_bucket_index(__b); - return local_iterator(_Base::end(__b), __b, this); + return local_iterator(_Base::end(__b), this); } const_local_iterator begin(size_type __b) const { __glibcxx_check_bucket_index(__b); - return const_local_iterator(_Base::begin(__b), __b, this); + return const_local_iterator(_Base::begin(__b), this); } const_local_iterator end(size_type __b) const { __glibcxx_check_bucket_index(__b); - return const_local_iterator(_Base::end(__b), __b, this); + return const_local_iterator(_Base::end(__b), this); } const_local_iterator cbegin(size_type __b) const { __glibcxx_check_bucket_index(__b); - return const_local_iterator(_Base::cbegin(__b), __b, this); + return const_local_iterator(_Base::cbegin(__b), this); } const_local_iterator cend(size_type __b) const { __glibcxx_check_bucket_index(__b); - return const_local_iterator(_Base::cend(__b), __b, this); + return const_local_iterator(_Base::cend(__b), this); } size_type