Levente Uzonyi uploaded a new version of Collections to project The Trunk: http://source.squeak.org/trunk/Collections-ul.488.mcz
==================== Summary ====================
Name: Collections-ul.488 Author: ul Time: 19 August 2012, 11:26:54.909 am UUID: a2927620-f372-1f4e-8e29-b6a5ff77fa9f Ancestors: Collections-cwp.487
Updated String >> #unescapePercentsRaw - it always returns the receiver if it is not percent-encoded - the implementation is simpler and slightly faster
=============== Diff against Collections-cwp.487 ===============
Item was changed: ----- Method: String>>unescapePercentsRaw (in category 'converting') ----- unescapePercentsRaw + "Decode myself if I'm percent-encoded, also replace + with space. Return self if the encoding is not valid." - "decode string including %XX form" + ^String new: self size streamContents: [ :stream | + | value1 value2 specialChars startIndex endIndex | + specialChars := '+%' asCharacterSet. + startIndex := 1. + [ (endIndex := self indexOfAnyOf: specialChars startingAt: startIndex) > 0 ] whileTrue: [ + stream next: endIndex - startIndex putAll: self startingAt: startIndex. + (self at: endIndex) == $% + ifTrue: [ + endIndex + 2 <= self size ifFalse: [ ^self ]. + value1 := (self at: endIndex + 1) asUppercase digitValue. + (value1 < 0 or: [ value1 > 15 ]) ifTrue: [ ^self ]. + value2 := (self at: endIndex + 2) asUppercase digitValue. + (value2 < 0 or: [ value2 > 15 ]) ifTrue: [ ^self ]. + stream nextPut: (Character value: value1 * 16 + value2). + startIndex := endIndex + 3 ] + ifFalse: [ "$+" + stream nextPut: Character space. + startIndex := endIndex + 1 ] ]. + startIndex <= self size ifTrue: [ + stream next: self size + 1 - startIndex putAll: self startingAt: startIndex ] ]! - | unescaped char asciiVal specialChars oldPos pos | - unescaped := ReadWriteStream on: String new. - specialChars := '+%' asCharacterSet. - oldPos := 1. - [pos := self indexOfAnyOf: specialChars startingAt: oldPos. - pos > 0] - whileTrue: [unescaped - nextPutAll: (self copyFrom: oldPos to: pos - 1). - char := self at: pos. - (char = $% - and: [pos + 2 <= self size]) - ifTrue: [asciiVal := (self at: pos + 1) asUppercase digitValue * 16 + (self at: pos + 2) asUppercase digitValue. - asciiVal > 255 - ifTrue: [^ self]. - unescaped - nextPut: (Character value: asciiVal). - pos := pos + 3. - pos <= self size - ifFalse: [char := nil]. - oldPos := pos] - ifFalse: [char = $+ - ifTrue: [unescaped nextPut: Character space] - ifFalse: [unescaped nextPut: char]. - oldPos := pos + 1]]. - oldPos <= self size - ifTrue: [unescaped - nextPutAll: (self copyFrom: oldPos to: self size)]. - ^unescaped contents!
packages@lists.squeakfoundation.org