https://bugs.kde.org/show_bug.cgi?id=507547

--- Comment #11 from Matthias Grimrath <[email protected]> ---
You dare to go, were I wouldn't, by using allocators :D

This, however, looks suspicious to me

inline bool inContainer() {
        const auto &a = container()->get_allocator();
        return this >= a.lastData && this < a.lastData + a.lastSize;

so the pointer is compared against the allocated memory. However, a pointer
somewhere into that allocated memory may not point to an actually used element.
We saw QVector<> reserving some space at the beginning to be able to quickly
insert elements at the top. And a STL implementation of std::vector<> is
probably allowed to do the same.

I don't know weather that leads to real-world problems. But I feel uneasy about
it.

I think a better approach would be to control insertion of new elements into
'm_lines' and update indices there, instead of hooking into QVector<> or
std::vector<> by template magic. Should be the same performance wise.

I'll work on a patch, having real code to show is probably better than
sophisticated arguments :D

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to