From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=3.0 tests=AWL,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 74A3D1F5AE for ; Fri, 17 Jul 2020 09:22:38 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id A122B12092F; Fri, 17 Jul 2020 18:22:05 +0900 (JST) Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id B8B65120929 for ; Fri, 17 Jul 2020 18:22:02 +0900 (JST) Received: by filterdrecv-p3mdw1-75c584b9c6-jl2gb with SMTP id filterdrecv-p3mdw1-75c584b9c6-jl2gb-19-5F116DD3-3B 2020-07-17 09:22:27.778058311 +0000 UTC m=+1786377.777619461 Received: from herokuapp.com (unknown) by geopod-ismtpd-5-2 (SG) with ESMTP id KGi9CgZGSliazW0fzdvlog for ; Fri, 17 Jul 2020 09:22:27.727 +0000 (UTC) Date: Fri, 17 Jul 2020 09:22:27 +0000 (UTC) From: eregontp@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 74989 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Feature X-Redmine-Issue-Id: 13381 X-Redmine-Issue-Author: eagletmt X-Redmine-Sender: Eregon X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?KippOI8ZHtTweq7XfQzW93937kJ4QNWwSBuHnaMEcr0oT3W1nYwjQs7F0lfmKI?= =?us-ascii?Q?vCAdEDf4VdA+fcG0aFc4N+eYbROcH6fm8Ne1uJA?= =?us-ascii?Q?A0W28oreDtyVTK9QjmkMSnURjOYnfZ0x3pK=2FyZV?= =?us-ascii?Q?spSb8MYP62G1jJc6Wu+k2ZcZ9ec+D9x4GQwFauh?= =?us-ascii?Q?mfWgiVYH7MWs1iz1F9m0oTfKfp6tqUvSFz8boXk?= =?us-ascii?Q?mI+t8DmVVpNs1AYZE=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 99200 Subject: [ruby-core:99200] [Ruby master Feature#13381] [PATCH] Expose rb_fstring and its family to C extensions X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #13381 has been updated by Eregon (Benoit Daloze). I'd suggest `buff` => `buffer`, I don't think it's worth abbreviating that. BTW, there is `rb_alloc_tmp_buffer` so `buff` would be inconsistent. Is `rb_str_pool(VALUE)` useful? I think it could be `rb_str_uminus()` (or just `rb_funcall(str, rb_intern("-@"))`). And then we could be consistent with `rb_str_new*`, and drop confusing `_buff` suffixes (not really buffer (=> sounds mutable), just a C string with known length). So I think this is better: ``` rb_str_uminus(VALUE) // or just rb_funcall(str, rb_intern("-@")) rb_str_pool(const char *ptr, long len) rb_str_pool_cstr(const char *ptr) rb_enc_str_pool(const char *ptr, long len, rb_encoding *enc) rb_enc_str_pool_cstr(const char *ptr, rb_encoding *enc) ``` ---------------------------------------- Feature #13381: [PATCH] Expose rb_fstring and its family to C extensions https://bugs.ruby-lang.org/issues/13381#change-86579 * Author: eagletmt (Kohei Suzuki) * Status: Assigned * Priority: Normal ---------------------------------------- https://github.com/ruby/ruby/pull/1559 Currently, C extensions cannot use fstrings. I'd like to use `rb_fstring_cstr` instead of `rb_str_new_cstr` for static strings in C extensions to avoid excess allocation. I think there's several use cases. - https://github.com/k0kubun/hamlit/blob/v2.8.0/ext/hamlit/hamlit.c#L508-L512 - https://bitbucket.org/ged/ruby-pg/src/e5eb92cca97abc0c6fc168acfad993c2ad314589/ext/pg_connection.c?at=v0.20.0&fileviewer=file-view-default#pg_connection.c-3679 - https://bitbucket.org/ged/ruby-pg/src/e5eb92cca97abc0c6fc168acfad993c2ad314589/ext/pg_copy_coder.c?at=v0.20.0&fileviewer=file-view-default#pg_copy_coder.c-38 -- https://bugs.ruby-lang.org/