From: Eric Wong <bofh@yhbt.net>
To: unicorn-public@yhbt.net
Subject: [PATCH] allow Ruby to deduplicate remaining globals
Date: Fri, 22 Oct 2021 04:05:16 +0000 [thread overview]
Message-ID: <20211022040516.17342-1-bofh@yhbt.net> (raw)
Most of these are bound to be used in Rack/Rails/apps/gems,
(though possibly with different encodings). Give Ruby
a chance to deduplicate them, at least.
---
ext/unicorn_http/common_field_optimization.h | 1 -
ext/unicorn_http/global_variables.h | 2 +-
ext/unicorn_http/unicorn_http.rl | 1 +
3 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/ext/unicorn_http/common_field_optimization.h b/ext/unicorn_http/common_field_optimization.h
index 0659fc7..250e43e 100644
--- a/ext/unicorn_http/common_field_optimization.h
+++ b/ext/unicorn_http/common_field_optimization.h
@@ -83,7 +83,6 @@ static void init_common_fields(void)
struct common_field *cf = common_http_fields;
char tmp[64];
- id_uminus = rb_intern("-@");
memcpy(tmp, HTTP_PREFIX, HTTP_PREFIX_LEN);
for(i = ARRAY_SIZE(common_http_fields); --i >= 0; cf++) {
diff --git a/ext/unicorn_http/global_variables.h b/ext/unicorn_http/global_variables.h
index f8e694c..c9ceebd 100644
--- a/ext/unicorn_http/global_variables.h
+++ b/ext/unicorn_http/global_variables.h
@@ -55,7 +55,7 @@ NORETURN(static void parser_raise(VALUE klass, const char *));
/** Defines global strings in the init method. */
#define DEF_GLOBAL(N, val) do { \
- g_##N = rb_obj_freeze(rb_str_new(val, sizeof(val) - 1)); \
+ g_##N = str_new_dd_freeze(val, (long)sizeof(val) - 1); \
rb_gc_register_mark_object(g_##N); \
} while (0)
diff --git a/ext/unicorn_http/unicorn_http.rl b/ext/unicorn_http/unicorn_http.rl
index 605b23f..ba23438 100644
--- a/ext/unicorn_http/unicorn_http.rl
+++ b/ext/unicorn_http/unicorn_http.rl
@@ -968,6 +968,7 @@ void Init_unicorn_http(void)
e414 = rb_define_class_under(mUnicorn, "RequestURITooLongError",
eHttpParserError);
+ id_uminus = rb_intern("-@");
init_globals();
rb_define_alloc_func(cHttpParser, HttpParser_alloc);
rb_define_method(cHttpParser, "initialize", HttpParser_init, 0);
reply other threads:[~2021-10-22 4:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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
List information: http://yhbt.net/unicorn/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211022040516.17342-1-bofh@yhbt.net \
--to=bofh@yhbt.net \
--cc=unicorn-public@yhbt.net \
/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.
Code repositories for project(s) associated with this public inbox
http://yhbt.net/unicorn.git/
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).