[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


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