Jean-Marc Lasgouttes wrote:
Abdelrazak Younes <[EMAIL PROTECTED]> writes:
In this case, this is more about encapsulation, not speed. 'Text'
should have no business in modifying the characters.
Depends. Paragraph used to be a container, you turn it into a do-all class.
No, I erased a lot of things from Paragraph (ParagraphMetrics/FontList
to name a few). I am just adding two methods, no big deal really.
Besides Paragraph was always more than a simple character container. I
am just hiding the implementation details so that we can cleanup this
mess without impacting everyone with each and every single cleanup.
So what is Text supposed to do?
Text is a Paragraph container. Actually most of the methods there should
become helper functions or Cursor methods. Text::changeCase() for
example have no business at all in Text. So is getWord(), selectWord(),
etc. If you want to complain about class being fatter, begin by erasing
those methods.
'Paragraph' owns the content so it should be the one that modifies
it. Besides, the code is stupid:
for (size_t i = 0; i < changes.size(); i++) {
insertChar(pos, changes[i],
getFontSettings(bparams,
erasePos),
trackChanges);
if (!eraseChar(erasePos, trackChanges)) {
++erasePos;
++pos; // advance
++right; // expand selection
}
There is nothing in this code the _requires_ being in Paragraph
(unless you turned everything into private methods).
Year and that's exactly my point and why it is stupid, because it uses
public interface whereas it can do things much more efficiently by
accessing directly to the data.
Programming with optimization in mind almost always results in good
code.
I am definitely not sure about that.
I am. "optimisation" is maybe not the good word but a good programmer
should always have efficiency in mind when programming, *always*.
Abdel.