patchgperf - Patches: patch #9562, Speed up step 4 of...

 
 

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

patch #9562: Speed up step 4 of Search::find_positions()

Submitter:  Frank Wojcik <fwojcik>
Submitted:  Sat 10 Feb 2018 01:01:52 AM UTC
   
 
Category:  None Priority:  5 - Normal
Status:  Done Privacy:  Public
Assigned to:  haible Open/Closed:  Closed

Sat 08 Sep 2018 02:10:49 PM UTC, comment #1: 

Thanks. I noticed the same thing after handling patch #9561.

> the i2 loop body will never execute if i1 == -1

Yes, but this is the kind of micro-optimizations that make code hard to read.

Bruno Haible <haible>
Group administrator
Sat 10 Feb 2018 01:01:52 AM UTC, original submission:  

Step 4 of Search::find_positions() iterates over all valid pairs of keyword positions to remove. However, removing (x, y) is exactly the same as removing (y, x), meaning the search space is currently iterated over twice as much as it needs to be. The bounds of the for() loops can be rewritten such that it is searched only once.

This diff builds off the one in patch #9561.

As a minor note, I left the bound for i1 in this patch to be 'i1 >= -1', even though the i2 loop body will never execute if i1 == -1. This way it is the same as the other for() loops in this function. It might be better to make the bounds be >= 0 explicitly, as this will remove any possible confusion over why only i2 is tested against -1 in the loop body.

Frank Wojcik <fwojcik>

 

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

Attached Files
file #43225:  fastersearch.diff added by fwojcik (1KiB - 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 haible (Posted a comment)
  • -email is unavailable- added by fwojcik (Submitted the item)
  •  

    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.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-09-08 haible StatusNone Done
        Assigned toNone haible
        Open/ClosedOpen Closed
    2018-02-10 fwojcik Attached File- Added fastersearch.diff, #43225

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code