now about arrays. Everybody knows, that dynamic allocation is bad thing, especially in optimized applications. Fragmentations, locks, time to find free block etc. General advice is to avoid any kind of dynamic allocation in update loop. So I decided to remove it everywhere and move all dynamic data to the stack.
There were many std::vectors, std::strings in the source, around 700 cases of using std::string, same for vector. Firstly I changed vector into C arrays, but it's not convenient to use. After that I found boost::array, but it's not dynamic.
So my decision was to create mix of boost::array and std::vector, it's based on sources of boost::array, but has ability to dynamically grew (one additional variable m_size).
Useful and looks optimal.
UPD. maybe not so optimal for complex objects with not simple constructors and also for big object, but optimal for pointers and simple types.
Комментариев нет:
Отправить комментарий