-
Notifications
You must be signed in to change notification settings - Fork 183
Optimize ExtractXML() calls by avoiding unnecessary string copies #1419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize ExtractXML() calls by avoiding unnecessary string copies #1419
Conversation
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())); |
There was a problem hiding this comment.
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 🙂
There was a problem hiding this 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.
The const ref parameter is good optimization. |
@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. |
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).
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.