On 2017-07-31 13:11, Mandeep Sandhu wrote: > Right now, I'm detaching the linked list during copy-construction (and > assignment). Detaching here means re-populating the LL with same entries > and then storing the new LL iterator's in the hash. > > For implicit sharing, I'll have to this instead when a non-const function > is called for the first time on the copy. This will cause a penalty when > calling such a function as the hash has to be repopulated with all entries > (eg: calling remove on the copy will take linear time instead of constant, > although subsequent calls will have no penalty). Still thinking about it.
So... right now your copy ctor is O(N) and remove is O(1), correct? Implicit sharing makes your copy ctor O(1) and detach() O(N). IOW, you've just deferred the copy cost until a non-const method is called. That's basically what COW does... (p.s. This thread should probably be on inter...@qt-project.org...) -- Matthew _______________________________________________ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development