"Premature optimization is the root of all evil" - Don Knuth

This is a pretty contrived example. I would argue that neither of the
two options presented are optimal for your particular example. My method
3 from the attached program is actually shown to be faster since here
the clearing is redundant. See, it's easy to make a point with a random
example. ;)

However, just because something is nanoseconds faster doesn't mean it is
the best solution. I would argue that code readability and
maintainability are usually more important. For this reason, I would
suggest that method 4 is the preferred approach out of the 4 even though
it is the second to last in speed. The reason for this is that it
reduces the scope of the string to inside the loop where it belongs
(RAII) and has the clearest intent. This applies to variables re-used
within a loop. For class member strings that are re-used within multiple
methods and can't be made local variables I would probably agree that
clear() has the best readability. But in all cases the decision should
be made based upon readability and maintainability versus an
infinitesimal saving in speed.

Output of test2:
method 1: 260000
method 2: 670000
method 3: 180000
method 4: 590000

** Attachment added: "test2.cpp"
   
https://bugs.launchpad.net/dcplusplus/+bug/250149/+attachment/1753755/+files/test2.cpp

-- 
You received this bug notification because you are a member of
Dcplusplus-team, which is subscribed to DC++.
https://bugs.launchpad.net/bugs/250149

Title:
  Retry on more possible Coral errors

Status in DC++:
  In Progress

Bug description:
  From 0.707 it retiries automatically if the Coral network is not connectable. 
However, there's still a problem when a transfer fails from Coral or if a Coral 
server responds with a HTTP error. Devs of DC++ mods also reported this 
problem, adding that either all kinds of Coral errors should be handled or it 
should be disabled by default in the further releases. Here is a patch that 
solves the rest of the problems. Also it seems that the problem when Coral 
network overloaded so it redirected to a page informing about the network 
problems is changed. It gives HTTP 503 - Service unavailable for some time, so 
with the patch this shoud be handled as well.



_______________________________________________
Mailing list: https://launchpad.net/~linuxdcpp-team
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~linuxdcpp-team
More help   : https://help.launchpad.net/ListHelp

Reply via email to