Skip to content

Conversation

cyrossignol
Copy link
Member

@cyrossignol cyrossignol commented Mar 18, 2019

Low-hanging fruit: calls to ExtractXML() passed input by value, which results in a at least one extra copy operation per invocation. The application uses this function everywhere, so we can reduce a little bit of overhead by passing references.

Also, this removes the forward declaration from files that don't use it.

string::size_type loc_end = XMLdata.find( key_end, loc+3);
if (loc_end != string::npos )
{
extraction = XMLdata.substr(loc+(key.length()),loc_end-loc-(key.length()));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...and one unnecessary move operation 🙂

Copy link
Member

@jamescowens jamescowens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. In the original scraper prototype, where Paul had defined this locally in scraper.cpp (see https://github.com/gridcoin-community/ScraperProxy/blob/master/scraper.cpp), he appropriately made changes to passing the arguments by reference, but maintained the intermediate variable.

This was lost when I fully developed the scraper and then used the already provided ExtractXML calls.

I agree with not using the intermediate variable, as readability is not impacted for something so simple, and given the frequency this is used, results in a good optimization.

@jamescowens jamescowens added this to the Denise milestone Mar 18, 2019
@tomasbrod
Copy link
Member

The const ref parameter is good optimization.
The other one, move elimination, is IHMO unnecessary. A decent CSE optimizer should be able to eliminate it.

@cyrossignol
Copy link
Member Author

cyrossignol commented Mar 18, 2019

@tomasbrod I agree--it's insignificant after everything else. I was just being silly 🙂

I find the code just a tiny bit easier to read without it, though.

@denravonska denravonska merged commit 295410f into gridcoin-community:development Mar 20, 2019
denravonska added a commit that referenced this pull request May 10, 2019
Added:
 - Replace NeuralNetwork with portable C++ scraper #1387 (@jamescowens,
   @tomasbrod, @Cycy, @TheCharlatan, @denravonska).
 - Allow compile flags to be used for depends #1423 (@G-UK).
 - Add stake splitting and side staking info to getmininginfo #1424
   (@jamescowens).
 - Add freedesktop.org desktop file and icon set #1438 (@a123b).

Changed:
 - Disable Qt for windows Travis builds #1276 (@TheCharlatan).
 - Replace use of AppCache PROJECT section with strongly-typed structures #1415
   (@cyrossignol).
 - Change dumpwallet to use appropriate data directory #1416 (@jamescowens).
 - Optimize ExtractXML() calls by avoiding unnecessary string copies #1419
   (@cyrossignol).
 - Change signature of IsLockTimeWithinMinutes #1422 (@jamescowens).
 - Restore old poll output for getmininginfo RPC #1437 (@a123b).
 - Prevent segfault when using rpc savescraperfilemanifest #1439 (@jamescowens).
 - Improve miner status messages for ineligible staking balances #1447
   (@cyrossignol).
 - Enhance scraper log archiving #1449 (@jamescowens).

Fixed:
 - Re-enable full GUI 32-bit Windows builds - part of #1387 (@jamescowens).
 - Re-activate Windows Installer #1409 (@TheCharlatan).
 - Fix Depends and Travis build issues for ARM #1417 (@jamescowens).
 - Fix syncupdate icons #1421 (@jamescowens).
 - Fix potential BOINC crash when reading projects #1426 (@cyrossignol).
 - Fix freeze when unlocking wallet #1428 (@denravonska).
 - Fix RPC after high priority alert #1432 (@denravonska).
 - Fix missing poll in GUI when most recent poll expired #1455 (@cyrossignol).

Removed:
 - Remove old, rudimentary side staking implementation #1381 (@denravonska).
 - Remove auto unlock #1402 (@denravonska).
 - Remove superblock forwarding #1430 (@denravonska).
@cyrossignol cyrossignol deleted the optimize-extractxml branch August 11, 2019 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants