Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] Styled text widget and TextStyle redundancy question

Thank you for the explanation.  I see that the problem is with Eclipse, since they apparently do not use those interfaces.

On 4/16/2012 12:57 PM, Silenio Quarti wrote:

StyleRange predates TextStyle.  TextStyle was added in Eclipse 3.2 to solve this performance issue.   We could not break existing users of the StyledText API and that is why StyleRange extends TextStyle.   The problem with StyleRange is that it contains the start,length offsets, so it cannot be reused for multiple ranges.

There is API in StyledText that let you reuse instances of StyleRange by passing the ranges as a separate parameter. See

org.eclipse.swt.custom.StyledText.setStyleRanges(int, int, int[], StyleRange[])
org.eclipse.swt.custom.StyledText.setStyleRanges(int[], StyleRange[])
org.eclipse.swt.custom.StyledText.getRanges()
org.eclipse.swt.custom.StyledText.getStyleRanges(boolean)

Also, StyleRanges are compacted internally if older APIs are used. Take a look at StyledTextRenderer.COMPACT_STYLES.

Silenio



From: Bill Fenlason <billfen@xxxxxxxxxx>
To: platform-swt-dev@xxxxxxxxxxx
Date: 04/16/2012 12:09 PM
Subject: [platform-swt-dev] Styled text widget and TextStyle redundancy        question
Sent by: platform-swt-dev-bounces@xxxxxxxxxxx





The TextStyle object contains the information (12 fields)  necessary to
control the display format of data fields within a StyledText widget.

Because the StyleRange object extends the TextStyle object rather than
containing a reference, and because a separate StyleRange object is
required for each StyledText data field, it seems to me that there is
potentially a large amount of unnecessary redundancy.

For example, consider a large, fully tokenized and syntax colored file
using a standard Eclipse editor and presentation manager.  There could
be many thousand redundant TextStyle fields.

Wouldn't it be better if TextStyle information were shared?

Is this analysis correct?  Does anyone else see this as a performance
and efficiency problem which should be addressed?

Bill Fenlason

_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev





_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev


No virus found in this message.
Checked by AVG - www.avg.com
Version: 2012.0.1913 / Virus Database: 2411/4940 - Release Date: 04/16/12


Back to the top