From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Mark Oteiza Newsgroups: gmane.emacs.bugs Subject: bug#28362: 26.0.50; [PATCH] gensym in core elisp Date: Tue, 5 Sep 2017 13:27:33 -0400 Message-ID: <20170905172733.GA10016@holos.localdomain> References: <8737812hqc.fsf@holos> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="ReaqsoxgOBHFXBhH" Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1504632533 9555 195.159.176.226 (5 Sep 2017 17:28:53 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 5 Sep 2017 17:28:53 +0000 (UTC) User-Agent: Mutt/1.9.0 (2017-09-02) To: 28362@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Sep 05 19:28:40 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dpHe9-0000zO-Bn for geb-bug-gnu-emacs@m.gmane.org; Tue, 05 Sep 2017 19:28:21 +0200 Original-Received: from localhost ([::1]:60331 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpHeG-0000oV-6h for geb-bug-gnu-emacs@m.gmane.org; Tue, 05 Sep 2017 13:28:28 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49298) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpHe0-0000jw-8O for bug-gnu-emacs@gnu.org; Tue, 05 Sep 2017 13:28:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpHdv-0003FJ-Ig for bug-gnu-emacs@gnu.org; Tue, 05 Sep 2017 13:28:12 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:43041) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dpHdv-0003Er-DR for bug-gnu-emacs@gnu.org; Tue, 05 Sep 2017 13:28:07 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dpHdp-0001Mq-V2 for bug-gnu-emacs@gnu.org; Tue, 05 Sep 2017 13:28:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mark Oteiza Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 05 Sep 2017 17:28:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28362 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 28362-submit@debbugs.gnu.org id=B28362.15046324615226 (code B ref 28362); Tue, 05 Sep 2017 17:28:01 +0000 Original-Received: (at 28362) by debbugs.gnu.org; 5 Sep 2017 17:27:41 +0000 Original-Received: from localhost ([127.0.0.1]:51722 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dpHdV-0001ME-F1 for submit@debbugs.gnu.org; Tue, 05 Sep 2017 13:27:41 -0400 Original-Received: from mail-qt0-f182.google.com ([209.85.216.182]:33609) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dpHdU-0001Lz-C0 for 28362@debbugs.gnu.org; Tue, 05 Sep 2017 13:27:40 -0400 Original-Received: by mail-qt0-f182.google.com with SMTP id i50so13860580qtf.0 for <28362@debbugs.gnu.org>; Tue, 05 Sep 2017 10:27:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=udel-edu.20150623.gappssmtp.com; s=20150623; h=date:from:to:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=swV+XAb+FsZ+F4drwUkoYNjtHjOACPUneFTb2K0Iwf4=; b=sPJvDjcJxoUmeCUNVDLH80EPWlGG5NddGKAw2E/B02gm9D8ETUTEqQBVpcXvD/mYp7 3cNSUSK6SIju4qkxD1KGB7Uuexvg/j2Y47N3p9Zp0yQfPOypESInG0YyR6cUy4ysi9PU 1+xEI7rKkvs0KXn3qumMYMLkcyrnf5c0u8I3JOV1/NEJ5sOglZBV31jCGBk0mXoHB5S0 WBxtS48/xoTeaDjRSoAItdxmrxN9wBQuUFmMdbqkXm7KPSXole3TsO5sW5/uL5cQd227 S1jMW7qGFS0iwIX/MvBHWG3c0EDDuFd4LCsO6d4YoHRxfDDVOWqXa6hdshnNIEl8sr9k TjhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=swV+XAb+FsZ+F4drwUkoYNjtHjOACPUneFTb2K0Iwf4=; b=E5i6u0DsR2T3N4maGrUNccBfsKq0lwXJx71cVSvwDwUS8PCahMn1FiDuuMWlMU9Z0a a4oFqwHM4LDZk9zAnmSTCwy/DGwxeIEuXjNyQsS4Tp9NcNGpm0SmX7XjN1bkFAafFOBP SGfZjwemRts88lzr5K9WSDOdvOGCNy+R6sZe/w7Bp2a5CDXnjT8AI40B9hvROxDuT1qX MBh1lR9top5PGuvUg9QOwDyJXc91v6NAGjlsZuEfIu8Flpo+UljVDyzTn/b1UefZ3lY2 c+qn6hEWEPNR1o/ptRivrU5nP721pFXTiJRK3dt+a7BoGwtkrCbMY9faQOz3hmYBQ2gW zloQ== X-Gm-Message-State: AHPjjUh1OnnhIHlN/CAaqRS49gcD+C8OI1swCM7JLEkBGF9emJO35D6Q QkoZboBe2tXc1xdnvFY6wg== X-Google-Smtp-Source: ADKCNb6l3gYhh4bJqvMm13HflE1tg+kSfR/URWb/7mKxJJmja78NxkVDeAa/F1JOrfO8bUIsNwh+vw== X-Received: by 10.237.33.253 with SMTP id m58mr6948531qtc.328.1504632454756; Tue, 05 Sep 2017 10:27:34 -0700 (PDT) Original-Received: from holos.localdomain (pool-173-67-36-61.bltmmd.fios.verizon.net. [173.67.36.61]) by smtp.gmail.com with ESMTPSA id r11sm765932qkh.80.2017.09.05.10.27.33 for <28362@debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Sep 2017 10:27:33 -0700 (PDT) Original-Received: by holos.localdomain (Postfix, from userid 1000) id 5B9EF68E72; Tue, 5 Sep 2017 13:27:33 -0400 (EDT) Content-Disposition: inline In-Reply-To: <8737812hqc.fsf@holos> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:136613 Archived-At: --ReaqsoxgOBHFXBhH Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit On 05/09/17 at 01:11pm, Mark Oteiza wrote: >I wrote a naïve gensym in C that is only about 1.5x to 2x faster than >cl-gensym (and incompatible because of the inaccessible counter). Patch >attached. There was a bunch of other crap in that patch--clean one attached. --ReaqsoxgOBHFXBhH Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="gensym_alloc_c.patch" diff --git a/src/alloc.c b/src/alloc.c index 2cee646256..89372c11b5 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -3632,6 +3632,32 @@ Its value is void, and its function definition and property list are nil. */) return val; } +static Lisp_Object default_gensym_prefix; + +DEFUN ("gensym", Fgensym, Sgensym, 0, 1, 0, + doc: /* Return a new uninterned symbol. +The name is made by concatenating PREFIX with a counter value. +PREFIX is a string and defaults to "g". +There is no provision for resetting the counter. */) + (Lisp_Object prefix) +{ + static int gensym_counter = 0; + + Lisp_Object suffix, name; + int len; + char buf[INT_STRLEN_BOUND (EMACS_INT)]; + + if (NILP (prefix)) + prefix = default_gensym_prefix; + CHECK_STRING (prefix); + + EMACS_INT count = gensym_counter++; + len = sprintf (buf, "%"pI"d", count); + suffix = make_string (buf, len); + name = concat2 (prefix, suffix); + return Fmake_symbol (name); +} + /*********************************************************************** @@ -7515,6 +7541,8 @@ The time is in seconds as a floating point value. */); DEFVAR_INT ("gcs-done", gcs_done, doc: /* Accumulated number of garbage collections done. */); + default_gensym_prefix = build_pure_c_string ("g"); + defsubr (&Scons); defsubr (&Slist); defsubr (&Svector); @@ -7527,6 +7555,7 @@ The time is in seconds as a floating point value. */); defsubr (&Smake_string); defsubr (&Smake_bool_vector); defsubr (&Smake_symbol); + defsubr (&Sgensym); defsubr (&Smake_marker); defsubr (&Smake_finalizer); defsubr (&Spurecopy); --ReaqsoxgOBHFXBhH--