From: Xi Ruoyao <xry111@mengyan1223.wang>
To: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org
Cc: Oleksandr Kulkov <aleksandr.kulkov@phystech.edu>,
Raihat Zaman Neloy <raihatneloy1992@gmail.com>,
xry111@mengyan1223.wang
Subject: [PATCH 3/5] libstdc++: keep subtree sizes in pb_ds binary search trees (PR 81806)
Date: Mon, 13 Jul 2020 16:45:46 +0800 [thread overview]
Message-ID: <ef8cea36327a4e48e5f981e1c2321d72f0c4ff8e.camel@mengyan1223.wang> (raw)
In-Reply-To: <67798e6881dcc5612ef31ac6b98586dfa5d83695.camel@mengyan1223.wang>
[-- Attachment #1: Type: text/plain, Size: 480 bytes --]
> The second and third patch together resolve PR 81806.
The attached patch modifies split_finish to use the subtree size we maintained
in the previous patch, resolving libstdc++/81806.
libstdc++-v3/ChangeLog:
PR libstdc++/81806
* include/ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp
(split_finish): Use maintained size, instead of calling
std::distance.
--
Xi Ruoyao <xry111@mengyan1223.wang>
School of Aerospace Science and Technology, Xidian University
[-- Attachment #2: 0003-libstdc-use-maintained-size-when-split-pb_ds-binary-.patch --]
[-- Type: text/x-patch, Size: 1351 bytes --]
From 4434da1b2b45797204f4fd978dcc4fbba4b17c6e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?X=E2=84=B9=20Ruoyao?= <xry111@mengyan1223.wang>
Date: Fri, 10 Jul 2020 21:38:09 +0800
Subject: [PATCH 3/5] libstdc++: use maintained size when split pb_ds binary
search trees
libstdc++-v3/ChangeLog:
PR libstdc++/81806
* include/ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp
(split_finish): Use maintained size, instead of calling
std::distance.
---
.../ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp
index d08288f186d..fb924b4434b 100644
--- a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp
+++ b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp
@@ -133,7 +133,9 @@ PB_DS_CLASS_C_DEC::
split_finish(PB_DS_CLASS_C_DEC& other)
{
other.initialize_min_max();
- other.m_size = std::distance(other.begin(), other.end());
+ other.m_size = 0;
+ if (other.m_p_head->m_p_parent != 0)
+ other.m_size = other.m_p_head->m_p_parent->m_subtree_size;
m_size -= other.m_size;
initialize_min_max();
PB_DS_ASSERT_VALID((*this))
--
2.27.0
next prev parent reply other threads:[~2020-07-13 8:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-13 8:37 [PATCH 0/5] " Xi Ruoyao
2020-07-13 8:39 ` Xi Ruoyao
2020-07-13 8:40 ` [PATCH 1/5] " Xi Ruoyao
2020-07-13 8:42 ` [PATCH 2/5] " Xi Ruoyao
2020-07-13 8:45 ` Xi Ruoyao [this message]
2020-07-13 8:48 ` [PATCH 4/5] " Xi Ruoyao
2020-07-13 8:51 ` [PATCH 5/5] " Xi Ruoyao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ef8cea36327a4e48e5f981e1c2321d72f0c4ff8e.camel@mengyan1223.wang \
--to=xry111@mengyan1223.wang \
--cc=aleksandr.kulkov@phystech.edu \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
--cc=raihatneloy1992@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).