[Interest] Interest Digest, Vol 80, Issue 8
Roland Hughes
roland at logikalsolutions.com
Sat May 12 16:11:57 CEST 2018
On 05/12/2018 08:57 AM, Thiago Macieira wrote:
> I'm claiming that Qt is run 1% of the time in big-endian mode. Explain to me
> why the 99% should perform the byte swap.
Because that class was created to communicate with the big-endian world
of real computers. Do not change the default. Feel free to create a
different class, QWannaBeDataStream or some such name, but there is an
installed base of code in production expecting the existing default
behavior.
Before anyone pipes up with a silly little "You should never rely on
defaults" response, I will ask
Just how many of you physically initialize a QString at point of
declaration?
None of you. The historical default behavior of the class is to
initialize it.
Visualize somebody arbitrarily deciding that default was a needless
processing burden so they took it out and rolled that code into the new
baseline. Just how good is your code going to work?
If you're not statically compiled and not running on a locked down
system (say a desktop application) the next automatic update from the
repos will shoot your application out of the saddle without you doing a
thing.
Think that is too much of a reach? Not a problem. How about we choose
one which is already 99% of the way there?
There is/was a .configure option or some other method of building Qt
from source which sets a fixed amount of preallocated string space. It's
a speed improvement for embedded targets with really crappy dynamic
memory allocation (most of them). How about someone realizing the
battery operated embedded processors _all_ had crappy dynamic memory
allocation and justifiably concluded the extra processor time on grid
connected computers was just a trifle so they change the build default?
This one is sweet. You can diff the code until the cows come home, but
you won't find the change. Not unless you go all the way out to the
build stuff.
Sounds tiny doesn't it?
Well, if you preallocate 15 bytes/characters, a newly created "empty"
string is now 15 bytes/characters long, not "". Just how many of you
always use .isEmpty() instead of an empty string compare? I haven't
opened up and looked at the isEmpty() code to see if it also honors the
compiled in preallocation amount. It would be interesting, from an
academic perspective, to see what it returns in the first two examples here:
https://doc.qt.io/archives/qt-4.8/qstring.html#isEmpty
Changing default behavior based on a single viewpoint, while a time
honored AGILE tradition, is always a bad thing. Then again, AGILE is
always a bad thing.
--
Roland Hughes, President
Logikal Solutions
(630)-205-1593
http://www.theminimumyouneedtoknow.com
http://www.infiniteexposure.net
http://www.johnsmith-book.com
http://www.logikalblog.com
http://www.interestingauthors.com/blog
http://lesedi.us/
http://onedollarcontentstore.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20180512/635a17cc/attachment.html>
More information about the Interest
mailing list