patchGNU Octave - Patches: patch #10216, interpreter: Avoid string...

 
 

patch #10216: interpreter: Avoid string construction 1

Submitter:  John W. Eaton <jwe>
Submitted:  Wed 22 Jun 2022 01:42:23 PM UTC
   
 
Category:  Core : other Priority:  5 - Normal
Status:  Done Privacy:  Public
Assigned to:  None Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 03 Nov 2022 01:32:27 PM UTC, comment #3: 

Closing as done because http://hg.savannah.gnu.org/hgweb/octave/rev/670a0d878af1 eliminated the std::string argument to the get_* functions declared in interpreter-private.h

John W. Eaton <jwe>
Group administrator
Wed 22 Jun 2022 09:22:53 PM UTC, comment #2: 

Ye c-string literals or void arg would do the trick too. With the added benefit of not needing the static std::string being initialized at program startup. I was kinda surprised std::string had this overhead actually.

Petter <petter>
Wed 22 Jun 2022 04:55:20 PM UTC, comment #1: 

Another possibility is to define these functions to accept "const char *" instead of "const std::string&" objects.  Almost all uses pass literal strings anyway.  We could also still provide the "const std::string&" signature as an inline wrapper function.

OTOH..  The "who" argument that is used in the error messages was intended to help with debugging.  But these are internal private functions that are not intended to be part of the public API (the interpreter-private.h file is not installed).  And in http://hg.savannah.gnu.org/hgweb/octave/rev/5cb3a2bb5e1e I changed the _get_interpreter_function_ to do this:


    if (! interp)
      {
        abort ();
        error ("%s: interpreter context missing", who.c_str ());
      }


so the error message will never be displayed.  I'm not sure why I did that.  Maybe I was just trying to do some debugging and forgot to remove the call to abort when I was done?  Or maybe it was because calling "error" requires the interpreter to be present (oops!).  Anyway, maybe it would be simpler to just remove the "who" argument and if one of these functions is called when there is no interpreter object available, just print a simple message to std::cerr and abort?

I made that change here:  http://hg.savannah.gnu.org/hgweb/octave/rev/670a0d878af1

John W. Eaton <jwe>
Group administrator
Wed 22 Jun 2022 01:42:23 PM UTC, original submission:  

From Petter Tomner <petter>, extracted from the zip file attached to the following comment in the discourse thread "WIP stack VM f\
or Octave": https://octave.discourse.group/t/wip-stack-vm-for-octave/2884/10

Replace some string literals with const static string objects to avoid string construction and its malloc.

John W. Eaton <jwe>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #53334:  octave_30598.patch added by jwe (4KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by petter (Posted a comment)
  • -email is unavailable- added by jwe (Submitted the item)
  • -email is unavailable- added by jwe
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-11-03 jwe StatusReady For Test Done
        Open/ClosedOpen Closed
    2022-06-22 jwe StatusNone Ready For Test
    2022-06-22 jwe Attached File- Added octave_30598.patch, #53334
        Carbon-Copy- Added petter

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code