You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2025/04/22 03:52:37 UTC
(couchdb) branch main updated: Use persistent terms to cache Mango RE expressions
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb.git
The following commit(s) were added to refs/heads/main by this push:
new dda8e6e8a Use persistent terms to cache Mango RE expressions
dda8e6e8a is described below
commit dda8e6e8a8af91efaf26f92e56597be40fac4682
Author: Nick Vatamaniuc <va...@gmail.com>
AuthorDate: Mon Apr 21 19:23:33 2025 -0400
Use persistent terms to cache Mango RE expressions
Persistent terms are built-in nowadays, and `mochiglobal:put/2` with a regex
compiled object is incompatible with OTP28, so we're killing two birds with one
stone here.
---
src/mango/src/mango_util.erl | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/mango/src/mango_util.erl b/src/mango/src/mango_util.erl
index c7ab1c8a6..32d75000b 100644
--- a/src/mango/src/mango_util.erl
+++ b/src/mango/src/mango_util.erl
@@ -340,10 +340,10 @@ is_number_string(Value) when is_list(Value) ->
end.
cached_re(Name, RE) ->
- case mochiglobal:get(Name) of
+ case persistent_term:get({?MODULE, Name}, undefined) of
undefined ->
{ok, MP} = re:compile(RE),
- ok = mochiglobal:put(Name, MP),
+ ok = persistent_term:put({?MODULE, Name}, MP),
MP;
MP ->
MP
@@ -400,6 +400,6 @@ is_number_string_test() ->
?assert(is_number_string("-1.0")),
?assertNot(is_number_string("hello")),
?assertNot(is_number_string("")),
- ?assertMatch({match, _}, re:run("1.0", mochiglobal:get(mango_numstring_re))).
+ ?assertMatch({match, _}, re:run("1.0", persistent_term:get({?MODULE, mango_numstring_re}))).
-endif.