QCAD Bugtracker

  • Status Closed
  • Percent Complete
    100%
  • Task Type Performance Issue
  • Category dxflib
  • Assigned To
    Andrew
  • Operating System All
  • Severity Low
  • Priority Very Low
  • Reported Version 3.12.1
  • Due in Version Undecided
  • Due Date Undecided
  • Votes
  • Private
Attached to Project: QCAD Bugtracker
Opened by Michael Zeilfelder - 20.11.2015
Last edited by Andrew - 15.12.2015

FS#1305 - Bottleneck in DL_Dxf::toReal caused by std::locale

Loading any larger dxf file takes very long because of this line:
istr.imbue(std::locale(”C”));

The call to std::locale is very slow. File-loading can be speed up by approximately factor 5 times on my system when replacing it. I just removed that line and instead added the following in DL_Dxf::in so it is changed only once per file:

std::locale oldLocale = std::locale::global(std::locale(”C”)); // use dot in numbers
while (readDxfGroups(fp, creationInterface)) {}
std::locale::global(oldLocale);

Closed by  Andrew
15.12.2015 13:29
Reason for closing:  Implemented
Additional comments about closing:  

https://github.com/qcad/qcad/commit/2 ba17b59dc57757ad7916e71f29ab4339f9d68e9# diff-fe84f891ebda39715eecb8bfbfa8f323

Admin
Andrew commented on 20.11.2015 16:15

Thanks for your suggestion.

Needs serious testing on several platforms. Note that an error in this part has very bad consequences (slightly wrong, rounded coordinates when loading DXF files).

Michael Zeilfelder commented on 27.11.2015 11:06

Conversion still uses the same locale, just once instead of every time. There isn't another call in the lib to set the locale so far, so shouldn't be reset in between. Some risk if people use it in a thread while changing the locale in another thread at the same time I guess. And maybe some risk in case you have other functions in loading which depend on the locale. Like for example if you create strings somewhere which should use the users locale instead.

But definitely worth it for speed. I'm currently evaluating the lib and it makes a lot of difference in development since I no longer have to wait > 10 seconds each time I load my test-models :-)

Btw, I used the tool "Very sleepy" to find this, highly recommended in case you haven't run into it yet!

Loading...

Available keyboard shortcuts

Tasklist

Task Details

Task Editing