bugGNU nano - Bugs: bug #57090, [Task] optimize parse_mbchar() as...


You are not allowed to post comments on this tracker with your current authentication level.

bug #57090: [Task] optimize parse_mbchar() as it gets called lots of times

Submitted by:  Benno Schulenberg <bens>
Submitted on:  Sun 20 Oct 2019 05:18:37 PM UTC  
Severity:  1 - Wish Status:  Fixed
Assigned to:  Benno Schulenberg <bens> Open/Closed:  Closed

Thu 24 Oct 2019 03:34:38 PM UTC, comment #3: 

The speed of the two new routines has improved significantly.  Leaving things to settle for now.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Mon 21 Oct 2019 06:06:57 PM UTC, comment #2: 

Commit 3c695664 further optimizes the new advance_over() function, by eliding the call of is_cntrl_mbchar() and an 'if' for the plain ASCII case.

Eliding the call of is_cntrl_mbchar() for the UTF-8 case would be nice, because it could be a simpler version, but it would still duplicate some forty bytes of code.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Mon 21 Oct 2019 11:10:47 AM UTC, comment #1: 

Commit c2d8641f elides a NULL parameter (two machine instructions) and two unneeded ifs (four machine instructions).

With further reshuffling still more instructions can be eldided.  Will follow later.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Sun 20 Oct 2019 05:18:37 PM UTC, original submission:  

To see how often parse_mbchar() gets called, compile nano with gcc using the -pg option.  Then run:

  src/nano --ignore NEWS

and press ^V until reaching end-of-file, then press ^X.  Then run:

  gprof src/nano >list  &&  less list

See how parse_mbchar() and is_cntrl_mbchar() were called 240 thousand times.

Looking further down, all these calls of parse_mbchar() were made by either actual_x() or breadth().  Reducing the number of calls of these two functions would be good, but speeding up parse_mbchar() a bit will be an easy first step.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.


No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by bens (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.




    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-10-24 bens StatusReady For Test => Fixed
        Open/ClosedOpen => Closed
    2019-10-21 bens StatusIn Progress => Ready For Test
    2019-10-21 bens StatusNone => In Progress

    Back to the top

    Powered by Savane 3.5