Issue 4518 in pharo: Don't inline digitValue

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Issue 4518 in pharo: Don't inline digitValue

pharo
Status: Accepted
Owner: [hidden email]
Labels: Type-Squeak

New issue 4518 by [hidden email]: Don't inline digitValue
http://code.google.com/p/pharo/issues/detail?id=4518

In NumberParser, digitValue has been inlined because it was too slow.
This is not necessary anymore.
See

Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-nice.425.mcz

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

Name: Kernel-nice.425
Author: nice
Time: 15 March 2010, 12:18:40.839 am
UUID: 3c10b52e-83ec-404b-9db9-4fcdae5bb28f
Ancestors: Kernel-nice.424

Use Character>>digitValue..
Now that it is fast enough, there is no point in replicating the algorithm.

=============== Diff against Kernel-nice.424 ===============

Item was changed:
  ----- Method: NumberParser>>nextElementaryLargeIntegerBase: (in  
category 'parsing-large int') -----
  nextElementaryLargeIntegerBase: aRadix
        "Form an unsigned integer with incoming digits from sourceStream.
        Return this integer, or zero if no digits found.
        Stop reading if end of digits or if a LargeInteger is formed.
+       Count the number of digits and the position of lastNonZero digit  
and store them in instVar."
-       Count the number of digits and the position of lastNonZero digit  
and store them in instVar"

+       | value digit char |
-       | value digit code char |
        value := 0.
        nDigits := 0.
        lastNonZero := 0.
-       DigitValues ifNil: [self class initializeDigitValues].
-       "Avoid using digitValue which is awfully slow"
        [value isLarge or: [(char := sourceStream next) == nil
+               or: [digit := char digitValue.
-               or: [code := char charCode.
-                       digit := code < 256
-                               ifTrue: [DigitValues at: 1 + code]
-                               ifFalse: [char digitValue].
                        (0 > digit or: [digit >= aRadix])
                                and: [sourceStream skip: -1.
                                        true]]]]
                whileFalse: [
                        nDigits := nDigits + 1.
                        0 = digit
                                ifFalse: [lastNonZero := nDigits].
                        value := value * aRadix + digit].
        ^value!

Item was changed:
  Object subclass: #NumberParser
        instanceVariableNames: 'sourceStream base neg integerPart  
fractionPart exponent scale nDigits lastNonZero requestor failBlock'
+       classVariableNames: ''
-       classVariableNames: 'DigitValues'
        poolDictionaries: ''
        category: 'Kernel-Numbers'!

+ !NumberParser commentStamp: 'nice 3/15/2010 00:16' prior: 0!
- !NumberParser commentStamp: 'nice 3/14/2010 22:42' prior: 0!
  NumberParser is an abstract class for parsing and building numbers from  
string/stream.
  It offers a framework with utility methods and exception handling.

  Number syntax is not defined and should be subclassResponsibility.

- Note that class variable DigitValues is a duplication of Character class  
variable. This is only an optimization, decoding digitValues being a major  
contributor of algorithm cost.
-
  Instance variables:
  sourceStream <Stream> the stream of characters from which the number is  
read
  base <Integer> the radix in which to interpret digits
  neg <Boolean> true in case of minus sign
  integerPart <Integer> the integer part of the number
  fractionPart <Integer> the fraction part of the number if any
  exponent <Integer> the exponent used in scientific notation if any
  scale <Integer> the scale used in case of ScaledDecimal number if any
  nDigits <Integer> number of digits read to form an Integer
  lasNonZero <Integer> position of last non zero digit, starting at 1 from  
left, 0 if all digits are zero
  requestor <TextEditor | nil> can be used to insert an error message in the  
requestor
  failBlock <BlockClosure> Block to execute whenever an error occurs.
        The fail block can have 0, 1 or 2 arguments (errorString and source  
position)
+ !
-
- Class variables:
- DigitValues <Array of: Integer> this is a mapping character asciiCode + 1  
-> digit value (or -1 if character is not a digit)!

Item was removed:
- ----- Method: NumberParser classSide>>initializeDigitValues (in  
category 'class initialization') -----
- initializeDigitValues
-       "Initialize the well known digit value of ascii characters."
-
-       DigitValues := Array new: 256 withAll: -1.
-       0 to: 255 do: [:i | DigitValues at: i + 1 put: (Character value: i)  
digitValue]!

Item was removed:
- ----- Method: NumberParser classSide>>initialize (in category 'class  
initialization') -----
- initialize
-       self initializeDigitValues.!



_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4518 in pharo: Don't inline digitValue

pharo
Updates:
        Labels: 1.4

Comment #1 on issue 4518 by [hidden email]: Don't inline digitValue
http://code.google.com/p/pharo/issues/detail?id=4518

Thanks


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4518 in pharo: Don't inline digitValue

pharo
Updates:
        Status: FixProposed

Comment #2 on issue 4518 by [hidden email]: Don't inline digitValue
http://code.google.com/p/pharo/issues/detail?id=4518

(No comment was entered for this change.)


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4518 in pharo: Don't inline digitValue

pharo

Comment #3 on issue 4518 by [hidden email]: Don't inline digitValue
http://code.google.com/p/pharo/issues/detail?id=4518

See inbox, there is a SLICE


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4518 in pharo: Don't inline digitValue

pharo
Updates:
        Labels: -1.4 Milestone-1.4

Comment #4 on issue 4518 by [hidden email]: Don't inline digitValue
http://code.google.com/p/pharo/issues/detail?id=4518

(No comment was entered for this change.)


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4518 in pharo: Don't inline digitValue

pharo
Updates:
        Status: Closed

Comment #5 on issue 4518 by [hidden email]: Don't inline digitValue
http://code.google.com/p/pharo/issues/detail?id=4518

in 14036

Thanks nicolas


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker