Skip to content

GRUtf8CodecStream Latin1ToUtf8Encodings is a Global ... should be class var #3

Closed

Description

@dalehenrich
GRUtf8CodecStream
nextPutAll: aString
    "conversion of smaller string is faster if not using the changeClassTo: trick"
    binary
        ifTrue: [ stream nextPutAll: aString asString ]
        ifFalse: [ aString size > 8
                        ifTrue: [ stream nextPutAll: (aString encodeAsUTF8 changeClassTo: String) ]
                        ifFalse: [ | enc  str | enc := aString encodeAsUTF8. 
                                     str := String new: enc size.
                                    1 to: enc size do: [:idx | str at: idx put: (Character value: (enc at: idx)) ].
                                    stream nextPutAll: str ] ]


GRUtf8CodecStream
nextPut: aCharacter
    "old implementation is very slow !!"
"   self nextPutAll: (String with: aCharacter)"
    | codePoint |
    codePoint := aCharacter codePoint.
    codePoint > 127
        ifTrue: [ 
            codePoint > 255
                ifTrue: [ | enc str |
                        enc := (String with: aCharacter) encodeAsUTF8. 
                         str := String new: enc size.
                        1 to: enc size do: [:idx | str at: idx put: (Character value: (enc at: idx)) ].
                        stream nextPutAll: str ]
                ifFalse: [ stream nextPutAll: (Latin1ToUtf8Encodings at: codePoint + 1) ] ]
        ifFalse: [ stream nextPut: aCharacter ]

Activity

  1. dalehenrich commented on Jun 9, 2014

    @dalehenrich
    MemberAuthor

    additional info:

    BTW here is the initialization code:
    
    UserGlobals at: #Latin1ToUtf8Encodings put: (Array new: 256).
    1 to: 256 do:[ :index | index > 128 ifTrue: [Latin1ToUtf8Encodings at: index put: (String with: (Character codePoint: index - 1)) encodeAsUTF8 asString]  ]
  2. jbrichau commented on Oct 17, 2014

    @jbrichau
    Member

    @dalehenrich shall I integrate this in a new version of Grease? Or is there another concern why this was not yet included?

  3. dalehenrich commented on Oct 17, 2014

    @dalehenrich
    MemberAuthor

    no concerns ... just time:)

    On Fri, Oct 17, 2014 at 2:28 AM, Johan Brichau [email protected]
    wrote:

    @dalehenrich https://github.com/dalehenrich shall I integrate this in a
    new version of Grease? Or is there another concern why this was not yet
    included?

    —
    Reply to this email directly or view it on GitHub
    GsDevKit#3 (comment).

  4. added a commit that references this issue on Oct 19, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions