[squeak-dev] The Trunk: Network-ul.159.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Apr 1 21:56:32 UTC 2015


Levente Uzonyi uploaded a new version of Network to project The Trunk:
http://source.squeak.org/trunk/Network-ul.159.mcz

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

Name: Network-ul.159
Author: ul
Time: 1 April 2015, 11:44:21.852 pm
UUID: 22d0dece-43ac-4ce7-b81f-9516fccd1843
Ancestors: Network-ul.158

Use CharacterSet's #nonSeparators shared set instead of creating and storing another one in MailAddressTokenizer. Initialize other character sets lazily, and release them during cleanUp.

=============== Diff against Network-ul.158 ===============

Item was changed:
  Stream subclass: #MailAddressTokenizer
  	instanceVariableNames: 'cachedToken text pos'
+ 	classVariableNames: 'CSNonAtom CSParens CSSpecials'
- 	classVariableNames: 'CSNonAtom CSNonSeparators CSParens CSSpecials'
  	poolDictionaries: ''
  	category: 'Network-RFC822'!
  
  !MailAddressTokenizer commentStamp: '<historical>' prior: 0!
  Divides an address into tokens, as specified in RFC 822.  Used by MailAddressParser.!

Item was added:
+ ----- Method: MailAddressTokenizer class>>cleanUp: (in category 'class initialization') -----
+ cleanUp: aggressive
+ 
+ 	CSParens := CSSpecials := CSNonAtom := nil!

Item was removed:
- ----- Method: MailAddressTokenizer class>>initialize (in category 'class initialization') -----
- initialize
- 	"Initalize class variables using   MailAddressTokenizer initialize"
- 
- 	| atomChars |
- 
- 	CSParens := CharacterSet empty.
- 	CSParens addAll: '()'.
- 
- 	CSSpecials := CharacterSet empty.
- 	CSSpecials addAll: '()<>@,;:\".[]'.
- 
- 	CSNonSeparators := CharacterSet separators complement.
- 
- 
- 	"(from RFC 2822)"
- 	atomChars := CharacterSet empty.
- 	atomChars addAll: ($A to: $Z).
- 	atomChars addAll: ($a to: $z).
- 	atomChars addAll: ($0 to: $9).
- 	atomChars addAll: '!!#$%^''*+-/=?^_`{|}~'.
- 
- 	CSNonAtom :=  atomChars complement.!

Item was added:
+ ----- Method: MailAddressTokenizer class>>nonAtomSet (in category 'class initialization') -----
+ nonAtomSet
+ 	"(from RFC 2822)"
+ 
+ 	^CSNonAtom ifNil: [
+ 		CSNonAtom := CharacterSet new
+ 			addAll: ($A to: $Z);
+ 			addAll: ($a to: $z);
+ 			addAll: ($0 to: $9);
+ 			addAll: '!!#$%^''*+-/=?^_`{|}~';
+ 			complement ]!

Item was added:
+ ----- Method: MailAddressTokenizer class>>parenthesesSet (in category 'class initialization') -----
+ parenthesesSet
+ 
+ 	^CSParens ifNil: [ CSParens:= CharacterSet newFrom: '()' ]!

Item was added:
+ ----- Method: MailAddressTokenizer class>>specialsSet (in category 'class initialization') -----
+ specialsSet
+ 
+ 	^CSSpecials ifNil: [ CSSpecials := CharacterSet newFrom: '()<>@,;:\".[]' ]!

Item was changed:
  ----- Method: MailAddressTokenizer>>nextAtom (in category 'tokenizing') -----
  nextAtom
  	| start end |
  	start := pos.
+ 	pos := text indexOfAnyOf: self class nonAtomSet startingAt: start ifAbsent: [ text size + 1].
- 	pos := text indexOfAnyOf: CSNonAtom startingAt: start ifAbsent: [ text size + 1].
  	end := pos - 1.
  	^MailAddressToken
  		type: #Atom
  		text: (text copyFrom: start to: end)!

Item was changed:
  ----- Method: MailAddressTokenizer>>nextComment (in category 'tokenizing') -----
  nextComment
  	| start nestLevel paren |
  	start := pos.
  	pos := pos + 1.
  	nestLevel := 1.
  
  	[ nestLevel > 0 ] whileTrue: [
+ 		pos := text indexOfAnyOf: self class parenthesesSet startingAt: pos  ifAbsent: [ 0 ].
- 		pos := text indexOfAnyOf: CSParens startingAt: pos  ifAbsent: [ 0 ].
  		pos = 0 ifTrue: [ 
  			self error: 'unterminated comment.  ie, more (''s than )''s' ].
  
  		paren := self nextChar.
  		paren = $( ifTrue: [ nestLevel := nestLevel + 1 ] ifFalse: [ nestLevel := nestLevel - 1 ]].
  	^ MailAddressToken type: #Comment
  		text: (text copyFrom: start to: pos - 1)!

Item was changed:
  ----- Method: MailAddressTokenizer>>nextToken (in category 'tokenizing') -----
  nextToken
  	| c |
  	self skipSeparators.
  	c := self peekChar.
  	c ifNil: [ ^nil ].
  	c = $( ifTrue: [ ^self nextComment ].
  	c = $" ifTrue: [ ^self nextQuotedString ].
  	c = $[ ifTrue: [ ^self nextDomainLiteral ].
+ 	(self class specialsSet includes: c) ifTrue: [ ^self nextSpecial ].
- 	(CSSpecials includes: c) ifTrue: [ ^self nextSpecial ].
  	^self nextAtom!

Item was changed:
  ----- Method: MailAddressTokenizer>>skipSeparators (in category 'tokenizing') -----
  skipSeparators
+ 	pos := text indexOfAnyOf: CharacterSet nonSeparators  startingAt: pos  ifAbsent: [ text size + 1 ].!
- 	pos := text indexOfAnyOf: CSNonSeparators  startingAt: pos  ifAbsent: [ text size + 1 ].!



More information about the Squeak-dev mailing list