<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On 2013-09-04, at 21:41, Nicolas Cellier &lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.nice@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">A rapid review of senders indicates that Character asSymbol seems rather rare in a trunk image.<br><br>I found <br>#initTextConstants<br>#inOutdent:delta: (Character tab asSymbol asText which is rather crooked way of avoiding an allocation - String tab would allocate a new Object).</div></blockquote><div><br></div><div>Scanner&gt;&gt;scanToken appears to be the most often used sender, and may well be the original reason for caching the 1-char symbols.</div><div><br></div><div>It might be a good idea to time compilation of complex methods with and without OneCharacterSymbols. (my guess is it wouldn't make much of a difference these days)</div><div><br></div><div><span style="font-family: Helvetica; font-size: 12px; ">- Bert -</span></div><div><span style="font-family: Helvetica; font-size: 12px; "><br></span></div><br><blockquote type="cite"><div class="gmail_extra"><br><br><div class="gmail_quote">2013/9/4 Levente Uzonyi <span dir="ltr">&lt;<a href="mailto:leves@elte.hu" target="_blank">leves@elte.hu</a>&gt;</span><br><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto; ">
There's another user of OneCharacterSymbols: Character &gt;&gt; #asSymbol. I don't know how often it's used (my guess is that it's rarely used), or how much slower it would be, if we were removing OneCharacterSymbols. The implementation would change from<br>

<br>
&nbsp; &nbsp; &nbsp; &nbsp; ^Symbol internCharacter: self<br>
<br>
to<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp; ^Symbol intern: self asString<br>
<br>
Which means that an extra String will be created, and the lookup is done in the WeakSets, instead of an Array/WeakArray.<br>
<br>
<br>
Levente<br>
<br>
On Wed, 4 Sep 2013, Nicolas Cellier wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Well, as you were the last modifier, I prefer to have your advice :)<br>
<br>
Nicolas<br>
<br>
<br>
2013/9/4 Levente Uzonyi &lt;<a href="mailto:leves@elte.hu" target="_blank">leves@elte.hu</a>&gt;<br>
&nbsp; &nbsp; &nbsp; On Wed, 4 Sep 2013, <a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a> wrote:<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A new version of Collections was added to project The Inbox:<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://source.squeak.org/inbox/Collections-nice.530.mcz" target="_blank">http://source.squeak.org/<u></u>inbox/Collections-nice.530.mcz</a><br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ==================== Summary ====================<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Name: Collections-nice.530<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Author: nice<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Time: 4 September 2013, 2:21:28.852 am<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; UUID: d732aa23-1c77-4c1e-abc0-<u></u>d8d4506b7f9f<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Ancestors: Collections-ul.529<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Fix this:<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;self assert: (allSymbols select: [:s | s = '+']) size = 1.<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1) It is un-necessary to enumerate the 1-char symbols, they already are in SymbolTable (the first time they were created via #findIntern: or by virtue of last #rehash) !<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2) We can use a WeekArray rather than an Array because there is no point in keeping a reference to unused 1-char symbols.<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Maybe we should get rid of OneCharacterSymbols class var, but I didn't dare...<br>
<br>
<br>
I say we should nuke it. The only user is Symbol class &gt;&gt; #selectorsContaining:, but that method is pretty much broken:<br>
- it uses OneCharacterSymbols only for infix selectors<br>
- it can't find infix selectors longer than 2 characters<br>
- it tries to optimize some stuff, but wastes cycles on other stuff<br>
<br>
<br>
Levente<br>
<br>
<br>
&nbsp; &nbsp; &nbsp; =============== Diff against Collections-ul.529 ===============<br>
<br>
&nbsp; &nbsp; &nbsp; Item was changed:<br>
&nbsp; &nbsp; &nbsp; &nbsp;----- Method: Symbol class&gt;&gt;allSymbols (in category 'access') -----<br>
&nbsp; &nbsp; &nbsp; &nbsp;allSymbols<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "Answer all interned symbols"<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ^Array streamContents:[:s|<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s nextPutAll: NewSymbols.<br>
&nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s nextPutAll: OneCharacterSymbols.<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s nextPutAll: SymbolTable.<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ].<br>
&nbsp; &nbsp; &nbsp; &nbsp;!<br>
<br>
&nbsp; &nbsp; &nbsp; Item was changed:<br>
&nbsp; &nbsp; &nbsp; &nbsp;----- Method: Symbol class&gt;&gt;initialize (in category 'class initialization') -----<br>
&nbsp; &nbsp; &nbsp; &nbsp;initialize<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "Symbol initialize"<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Symbol rehash.<br>
&nbsp; &nbsp; &nbsp; + &nbsp; &nbsp; &nbsp; OneCharacterSymbols := WeakArray new: 256.<br>
&nbsp; &nbsp; &nbsp; + &nbsp; &nbsp; &nbsp; (0 to: 255) do: [ :byte | byte asCharacter asSymbol].<br>
&nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; OneCharacterSymbols := nil.<br>
&nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; OneCharacterSymbols := (1 to: 256) collect: [ :i | (i - 1) asCharacter asSymbol].<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Smalltalk addToShutDownList: self.<br>
&nbsp; &nbsp; &nbsp; &nbsp;!<br>
<br>
&nbsp; &nbsp; &nbsp; Item was changed:<br>
&nbsp; &nbsp; &nbsp; &nbsp;----- Method: Symbol class&gt;&gt;internCharacter: (in category 'instance creation') -----<br>
&nbsp; &nbsp; &nbsp; &nbsp;internCharacter: aCharacter<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aCharacter asciiValue &gt; 256 ifTrue:[^self intern: aCharacter asString].<br>
&nbsp; &nbsp; &nbsp; + &nbsp; &nbsp; &nbsp; ^(OneCharacterSymbols at: aCharacter asciiValue + 1) ifNil: [OneCharacterSymbols at: aCharacter asciiValue + 1 put: (self intern: aCharacter asString)]<br>
&nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; OneCharacterSymbols ifNil: [^self intern: aCharacter asString].<br>
&nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; ^OneCharacterSymbols at: aCharacter asciiValue + 1<br>
&nbsp; &nbsp; &nbsp; &nbsp;!<br>
<br>
&nbsp; &nbsp; &nbsp; Item was changed:<br>
&nbsp; &nbsp; &nbsp; &nbsp;----- Method: Symbol class&gt;&gt;selectorsContaining: (in category 'access') -----<br>
&nbsp; &nbsp; &nbsp; &nbsp;selectorsContaining: aString<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "Answer a list of selectors that contain aString within them. Case-insensitive. &nbsp;Does return symbols that begin with a capital letter."<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | size selectorList ascii |<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selectorList := OrderedCollection new.<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (size := aString size) = 0 ifTrue: [^selectorList].<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aString size = 1 ifTrue:<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ascii := aString first asciiValue.<br>
&nbsp; &nbsp; &nbsp; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ascii &lt; 128 ifTrue: [(OneCharacterSymbols at: ascii+1) ifNotNil: [:s | selectorList add: s]]<br>
&nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ascii &lt; 128 ifTrue: [selectorList add: (OneCharacterSymbols at: ascii+1)]<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ].<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (aString first isLetter or: [aString first isDigit]) ifFalse:<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aString size = 2 ifTrue:<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [Symbol hasInterned: aString ifTrue:<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [:s | selectorList add: s]].<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ^selectorList<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ].<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selectorList := selectorList copyFrom: 2 to: selectorList size.<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self allSymbolTablesDo: [:each |<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; each size &gt;= size ifTrue:<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [(each findSubstring: aString in: each startingAt: 1<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; matchTable: CaseInsensitiveOrder) &gt; 0<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ifTrue: [selectorList add: each]]].<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ^selectorList reject: [:each | "reject non-selectors, but keep ones that begin with an uppercase"<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; each numArgs &lt; 0 and: [each asString withFirstCharacterDownshifted numArgs &lt; 0]].<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp;"Symbol selectorsContaining: 'scon'"!<br>
<br>
<br>
<br>
<br>
<br>
<br>
</blockquote>
<br><br>
<br></blockquote></div><br></div>
<br></blockquote></div><div apple-content-edited="true"><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px; font-size: 12px; "><br class="Apple-interchange-newline"></span>

</div>
<br></body></html>