3 ms·
But we are talking about tabs here. Premature optimization is the root of all evil (to throw another cliché).
by danieldk 15y ago
But we are talking about tabs here. Premature optimization is the root of all evil (to throw another cliché).
- lylejohnson 15y agoSpoken by a man who has never encountered a "tabbed notebook"-style UI with multiple rows of tabs, stacked on top of each other. ;)
- lukeschlather 15y agoPremature optimization is the root of all evil, but removing from the beginning of any array-based growable structure rather than the beginning will turn a O(n) operation into an O(n^2) operation. And you don't know what's going into those tabs. That cliché shouldn't be used to excuse positively brain-dead choices.
- danieldk 15y agobut removing from the beginning of any array-based growable structure rather than the beginning will turn a O(n) operation into an O(n^2) operation. I'll bite: in arrays, front deletion (like back deletion) can be done in O(1) time. Keep a pointer to the first element, and just increment it upon front deletion (and free the element if necessary). Obviously, you may want to be smart to avoid memory use getting out of hand. And you don't know what's going into those tabs. If the array stores references (pointers), which you'd expect with tabs, that is orthogonal to the discussion. Whatever is going into those tabs, a pointer is a pointer.
- xentronium 15y ago> I'll bite: in arrays, front deletion (like back deletion) can be done in O(1) time. Keep a pointer to the first element, and just increment it upon front deletion (and free the element if necessary). Obviously, you may want to be smart to avoid memory use getting out of hand. Actually that's how they often do array-based queues and deques. To help with memory use they let the tail pointer overflow through the end (so you could have tail at index 2 and head at index 8).
- deleted 15y ago[deleted]
- sanderjd 15y agoI really like your insight about the accumulation of decisions over the course of a project - I've never thought about it in quite that way, that by having one default decision or the other, your project's destiny is completely different. Picking a sane default answer to that question for a project should be thought of as one of the (many) important jobs of its creator. edit: I really don't understand why the parent comment was downvoted and then deleted.