Yearly archives: 2018

23 posts

C++ Small string optimizations

One size does not fit all
One size does not fit all

What is “small string optimization”?

Standard C++  string stores its data on the heap. But that is only true if the string grows over an implementation-dependent size. That predefined size for std::string is/was 15 for MSVC and GCC and 23 for Clang.  That is: the C++ string stays “small” if you have not asked for bigger than 15/23 sized strings. The string will not attempt to grow its storage on the heap if it can stay small.

Heap memory allocations/de-allocations are taking a lot of time when compared to most standard C run time calls.

Thus if you avoid them your program will run faster and will consume less memory. Continue reading

C++ The Modern Factory

I think I have architected, designed and implemented, what might be a (bit) better  Factory Pattern. Of course, I am pretty sure someone else has discovered the same variation.

Of all the patterns, very often, I was particularly bothered with “classical” aka legacy, Factory. Yes, once implemented, you can relatively easily make it create new “things”, but on the design and usability level, to me,  it does not look very flexible and expandable.

On the C++ level, it requires code repetition and the use of smart pointers. In essence, these two combined, somehow do not look to me like modern C++ at all. Continue reading

Just say No to XML

just say no to xml

Children, that is the picture of “XML”. Document Markup Language. It was used by the end of the XX-th century.

This was a post from  May 2015. Unfortunately, it is still actual in May 2021.

This probably applies to you. Especially if you are a Developer.  Or if you suspect you might be a .NET Lemming? (A member of any large group following an unthinking course towards mass destruction)

.NET and SharePoint in particular are two likely offenders here. It is now 2021 (May) … Oops?

This subject (XML in software development) has been reiterated to death. And back.
Continue reading

C++: my own string comparisons


An Apple and an Orange. Not the same.


Probably this subject comes as a surprise. Most of the  Windows development population rarely (if ever) thinks of string comparison,  as a separate subject. Neither was I, until one recent day I foolishly clicked on that “Code Analyzer” menu entry in my Visual Studio while trying to make sense of the famous WINFILE source code.

Fast forward few days, Battle bruised and much wiser I have decided to write about my experiences.

Please proceed here for a riveting read. And some MSDN  rant too.