From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Bruce Korb Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH 1/1] scm_set_source_properties_x: optimize if only name, line, and/or col Date: Sun, 17 Jan 2021 14:55:53 -0800 Message-ID: <3a393e11-15b4-6504-47da-aea9e950446d@gnu.org> References: <20210117222458.902736-1-rlb@defaultvalue.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4901"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 To: Rob Browning , guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Sun Jan 17 23:56:07 2021 Return-path: Envelope-to: guile-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l1Gxq-0001CK-UW for guile-devel@m.gmane-mx.org; Sun, 17 Jan 2021 23:56:06 +0100 Original-Received: from localhost ([::1]:57806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l1Gxq-0003CL-0T for guile-devel@m.gmane-mx.org; Sun, 17 Jan 2021 17:56:06 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l1Gxg-0003CC-Pc for guile-devel@gnu.org; Sun, 17 Jan 2021 17:55:56 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:44092) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l1Gxg-0001fi-DI; Sun, 17 Jan 2021 17:55:56 -0500 Original-Received: from c-71-198-222-86.hsd1.ca.comcast.net ([71.198.222.86]:55654 helo=[172.16.16.102]) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1l1Gxf-0003T6-IE; Sun, 17 Jan 2021 17:55:55 -0500 In-Reply-To: <20210117222458.902736-1-rlb@defaultvalue.org> Content-Language: en-US X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.io gmane.lisp.guile.devel:20640 Archived-At: On 1/17/21 2:24 PM, Rob Browning wrote: > * libguile/srcprop.c (scm_set_source_properties_x): When only a subset > of file, line, and column fields are specified, store the data as a > srcprops object (tc16_srcprops) rather than an alist. > --- > > Proposed for at least 3.x. If we want some additional tests, then > one option might be a public or private predicate to test for a > srcprops object (at least for scheme level testing). Does this mean I can swap out this code for something better now? I've disliked this code for years. > static SCM > ag_scm_c_eval_string_from_file_line( >     char const * pzExpr, char const * pzFile, int line) > { >     SCM port = scm_open_input_string(AG_SCM_FROM_STR(pzExpr)); > >     if (OPT_VALUE_TRACE >= TRACE_EVERYTHING) >         fprintf(trace_fp, TRACE_EVAL_STRING, pzFile, line, pzExpr); > >     { >         static SCM    file      = SCM_UNDEFINED; >         static char * pzOldFile = NULL; > >         if ((pzOldFile == NULL) || (strcmp(pzOldFile, pzFile) != 0)) { >             if (pzOldFile != NULL) >                 AGFREE(pzOldFile); >             AGDUPSTR(pzOldFile, pzFile, "scheme source"); >             file = AG_SCM_FROM_STR(pzFile); >         } > >         { >             SCM ln = scm_from_int(line); >             scm_set_port_filename_x(port, file); >             scm_set_port_line_x(port, ln); >             scm_set_port_column_x(port, SCM_INUM0); >         } >     } > >     { >         SCM ans = SCM_UNSPECIFIED; > >         /* Read expressions from that port; ignore the values.  */ >         for (;;) { >             SCM form = scm_read(port); >             if (SCM_EOF_OBJECT_P(form)) >                 break; >             ans = scm_primitive_eval_x(form); >         } > >         return ans; >     } > }