From e9251fea2debebfebe1f762a4a8d5b3b1d4c75ef Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Mon, 10 Jul 2023 17:16:17 +0200 Subject: d: Merge upstream dmd, druntime a88e1335f7, phobos 1921d29df. D front-end changes: - Import dmd v2.104.1. - Deprecation phase ended for access to private method when overloaded with public method. D runtime changes: - Import druntime v2.104.1. - Linux input header translations were added to druntime. - Integration with the Valgrind `memcheck' tool has been added to the garbage collector. Phobos changes: - Import phobos v2.104.1. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd a88e1335f7. * dmd/VERSION: Bump version to v2.104.1. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime a88e1335f7. * src/MERGE: Merge upstream phobos 1921d29df. * config.h.in: Regenerate. * configure: Regenerate. * configure.ac (libphobos-checking): Add valgrind flag. (DRUNTIME_LIBRARIES_VALGRIND): Call. * libdruntime/Makefile.am (DRUNTIME_CSOURCES): Add etc/valgrind/valgrind_.c. (DRUNTIME_DSOURCES): Add etc/valgrind/valgrind.d. (DRUNTIME_DSOURCES_LINUX): Add core/sys/linux/input.d, core/sys/linux/input_event_codes.d, core/sys/linux/uinput.d. * libdruntime/Makefile.in: Regenerate. * m4/druntime/libraries.m4 (DRUNTIME_LIBRARIES_VALGRIND): Define. --- libphobos/src/std/regex/internal/ir.d | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'libphobos/src/std/regex') diff --git a/libphobos/src/std/regex/internal/ir.d b/libphobos/src/std/regex/internal/ir.d index ec0cb66..3b38f9c 100644 --- a/libphobos/src/std/regex/internal/ir.d +++ b/libphobos/src/std/regex/internal/ir.d @@ -49,10 +49,29 @@ CharMatcher[CodepointSet] matcherCache; } } -@property ref wordMatcher()() +// Force pure because that is needed +// Templated so that we don't pull in std.uni wordCharacter unnecessarily. +@property ref wordMatcher()() pure { - static immutable CharMatcher matcher = CharMatcher(wordCharacter); - return matcher; + static auto actual() + { + static CharMatcher matcher; + static bool haveMatcher; + + if (!haveMatcher) + { + matcher = CharMatcher(wordCharacter); + haveMatcher = true; + } + + return &matcher; + } + + // WORKAROUND: if the compiler won't memoize the output of the function for us, + // we'll do it with pure and there will be casts and it'll be happy about it. + // This is unfortunately needed to make std.regex as a whole faster to import & use + // in build times ~500ms. + return *(cast(immutable(CharMatcher)* function() @safe nothrow @nogc pure)&actual)(); } // some special Unicode white space characters -- cgit v1.1