[Review needed] Symbol allSymbols contains one-character symbols twice #11242

MD
Marcus Denker
Thu, May 19, 2022 8:57 AM

Symbol allSymbols asBag occurrencesOf: #a

allSymbols returns an array of all symbols. The reason it contains #a twice: There is OneCharacterSymbols.

  • it is initialized with:

    OneCharacterSymbols := (1 to: 256) collect: [ :i | (i - 1) asCharacter asSymbol].

the #asSymbol puts the OneCharacterSymbols in the main symbol table already.

Then OneCharacterSymbols is just used by #allSymbols and #selectorsContaining:, with the latter having no users.

https://github.com/pharo-project/pharo/pull/11241

Besides the bugfix, it removes some one Character symbols that never got used and speeds up #allSymbols a little.

And it simplifies the code related to the symbol table a little, which will make it easier to improve it later.

Marcus
Symbol allSymbols asBag occurrencesOf: #a allSymbols returns an array of all symbols. The reason it contains #a twice: There is OneCharacterSymbols. - it is initialized with: OneCharacterSymbols := (1 to: 256) collect: [ :i | (i - 1) asCharacter asSymbol]. the #asSymbol puts the OneCharacterSymbols in the main symbol table already. Then OneCharacterSymbols is just used by #allSymbols and #selectorsContaining:, with the latter having no users. https://github.com/pharo-project/pharo/pull/11241 Besides the bugfix, it removes some one Character symbols that never got used and speeds up #allSymbols a little. And it simplifies the code related to the symbol table a little, which will make it easier to improve it later. Marcus