[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/1] scm_set_source_properties_x: optimize if only name, line

From: Bruce Korb
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
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0

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
    char const * pzExpr, char const * pzFile, int line)
    SCM port = scm_open_input_string(AG_SCM_FROM_STR(pzExpr));

        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)
            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))
            ans = scm_primitive_eval_x(form);

        return ans;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]