aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/std/regex
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2021-08-09 11:49:09 +0100
committerJonathan Wakely <jwakely@redhat.com>2021-08-09 20:46:56 +0100
commitf5a2d78072fc161e8ca3117126030041f1503c3f (patch)
treeba78501ade69cba3dc0030ae7e8b6899b6082a33 /libstdc++-v3/include/std/regex
parent1354603bf7d2ef8cd0cb1f76e801732020502987 (diff)
downloadgcc-f5a2d78072fc161e8ca3117126030041f1503c3f.zip
gcc-f5a2d78072fc161e8ca3117126030041f1503c3f.tar.gz
gcc-f5a2d78072fc161e8ca3117126030041f1503c3f.tar.bz2
libstdc++: Reduce use of debug containers in <regex>
The std::regex code uses std::map and std::vector, which means that when _GLIBCXX_DEBUG is defined it uses the debug versions of those containers. That no longer compiles, because I changed <regex> to include <bits/stl_map.h> and <bits/stl_vector.h> instead of <map> and <vector>, so the debug versions aren't defined, and std::map doesn't compile. There is also a use of std::stack, which defaults to std::deque which is the debug deque when _GLIBCXX_DEBUG is defined. Using std::map, std::vector, and std::deque is probably a mistake, and we should qualify them with _GLIBCXX_STD_C instead so that the debug versions aren't used. We do not need the overhead of checking our own uses of those containers, which should be correct anyway. The exception is the vector base class of std::match_results, which exposes iterators to users, so can benefit from debug mode checks for its iterators. For other accesses to the vector elements, match_results already does its own checks, so can access the _GLIBCXX_STD_C::vector base class directly. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * include/bits/regex.h (basic_regex::transform_primary): Use _GLIBCXX_STD_C::vector for local variable. * include/bits/regex.tcc (__regex_algo_impl): Use reference to _GLIBCXX_STD_C::vector base class of match_results. * include/bits/regex_automaton.tcc (_StateSeq:_M_clone): Use _GLIBCXX_STD_C::map and _GLIBCXX_STD_C::deque for local variables. * include/bits/regex_compiler.h (_BracketMatcher): Use _GLIBCXX_STD_C::vector for data members. * include/bits/regex_executor.h (_Executor): Likewise. * include/std/regex [_GLIBCXX_DEBUG]: Include <debug/vector>.
Diffstat (limited to 'libstdc++-v3/include/std/regex')
-rw-r--r--libstdc++-v3/include/std/regex3
1 files changed, 3 insertions, 0 deletions
diff --git a/libstdc++-v3/include/std/regex b/libstdc++-v3/include/std/regex
index 04fb8b2..2c94fa3 100644
--- a/libstdc++-v3/include/std/regex
+++ b/libstdc++-v3/include/std/regex
@@ -55,6 +55,9 @@
#include <bits/stl_vector.h>
#include <bits/stl_bvector.h>
#include <bits/vector.tcc>
+#ifdef _GLIBCXX_DEBUG
+# include <debug/vector>
+#endif
#include <bits/regex_constants.h>
#include <bits/regex_error.h>
#include <bits/regex_automaton.h>