The Trunk: ShoutCore-ul.54.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: ShoutCore-ul.54.mcz

commits-2
Levente Uzonyi uploaded a new version of ShoutCore to project The Trunk:
http://source.squeak.org/trunk/ShoutCore-ul.54.mcz

==================== Summary ====================

Name: ShoutCore-ul.54
Author: ul
Time: 12 August 2015, 10:39:34.306 pm
UUID: 4329b6b2-95a5-4c41-8fe3-d489f4458293
Ancestors: ShoutCore-ul.53

- added missing #shoutParserClass to PseudoClass
- faster SHTextStylerST80>>setAttributesIn:fromRanges:

=============== Diff against ShoutCore-ul.53 ===============

Item was added:
+ ----- Method: PseudoClass>>shoutParserClass (in category '*ShoutCore') -----
+ shoutParserClass
+
+ ^SHParserST80
+ !

Item was changed:
  ----- Method: SHTextStylerST80>>setAttributesIn:fromRanges: (in category 'private') -----
  setAttributesIn: aText fromRanges: ranges
+
+ | defaultAttributes newRuns newValues lastAttributes oldRuns nextIndex lastCount |
- | charAttr defaultAttr attr newRuns newValues lastAttr oldRuns lastCount |
-
  oldRuns := aText runs.
+ defaultAttributes := self attributesFor: #default.
- defaultAttr := self attributesFor: #default.
- charAttr := Array new: aText size withAll: defaultAttr.
- ranges do: [ :range |
- (self attributesFor: range type) ifNotNil: [ :attribute |
- charAttr from: range start to: range end put: attribute ] ].
  newRuns := OrderedCollection new: ranges size * 2 + 1.
  newValues := OrderedCollection new: ranges size * 2 + 1.
+ lastAttributes := nil.
+ nextIndex := 1.
- lastAttr := nil.
  lastCount := 0.
+ ranges do: [ :range |
+ | attributes |
+ nextIndex < range start ifTrue: [
+ lastAttributes == defaultAttributes
+ ifTrue: [
+ lastCount := lastCount + range start - nextIndex.
+ newRuns at: newRuns size put: lastCount ]
+ ifFalse: [
+ lastCount := range start - nextIndex.
+ newRuns addLast: lastCount.
+ lastAttributes := defaultAttributes.
+ newValues addLast: lastAttributes ].
+ nextIndex := range start ].
+ attributes := (self attributesFor: range type) ifNil: [ defaultAttributes ].
+ lastAttributes == attributes
+ ifTrue: [
+ lastCount := lastCount + range end - nextIndex + 1.
- 1 to: charAttr size do: [ :i |
- (attr := charAttr at: i) == lastAttr
- ifTrue: [
- lastCount := lastCount + 1.
  newRuns at: newRuns size put: lastCount ]
  ifFalse: [
+ lastCount := range end - nextIndex + 1.
+ newRuns addLast: lastCount.
+ lastAttributes := attributes.
+ newValues addLast: lastAttributes ].
+ nextIndex := range end + 1 ].
+ nextIndex <= aText size ifTrue: [
+ lastAttributes == defaultAttributes
+ ifTrue: [
+ lastCount := lastCount + aText size - nextIndex + 1.
+ newRuns at: newRuns size put: lastCount ]
+ ifFalse: [
+ lastCount := aText size - nextIndex + 1.
+ newRuns addLast: lastCount.
+ lastAttributes := defaultAttributes.
+ newValues addLast: lastAttributes ] ].
- newRuns addLast: 1.
- lastCount := 1.
- lastAttr := newValues addLast: attr ] ].
  aText runs: (RunArray runs: newRuns values: newValues).
+ oldRuns withStartStopAndValueDo: [ :start :stop :attribs |
- oldRuns withStartStopAndValueDo:[:start :stop :attribs|
  (attribs anySatisfy: [ :each | each shoutShouldPreserve ]) ifTrue: [
  attribs do: [ :each | aText addAttribute: each from: start to: stop ] ] ].
  !