Levente Uzonyi uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-ul.959.mcz ==================== Summary ==================== Name: Kernel-ul.959 Author: ul Time: 10 October 2015, 3:44:26.604 pm UUID: 0b44d9be-d30e-4daf-8dfc-411b2000d574 Ancestors: Kernel-topa.958 Use #== instead of #= for symbol comparison and compare the floating point value directly to zero in Float >> #adaptTo*andCompare: methods. Also removed the branch for NaN, because the remaining branches yield the same result. Duration changes: - avoid LargeInteger operations in #days:hours:minutes:seconds:nanoSeconds: ad #asMilliSeconds as much as possible =============== Diff against Kernel-topa.958 =============== Item was changed: ----- Method: Duration class>>days:hours:minutes:seconds:nanoSeconds: (in category 'squeak protocol') ----- days: days hours: hours minutes: minutes seconds: seconds nanoSeconds: nanos + ^self + seconds: seconds + + (minutes * SecondsInMinute) + + (hours * SecondsInHour) + + (days * SecondsInDay) + nanoseconds: nanos - ^ self seconds: ((days * SecondsInDay) - + (hours * SecondsInHour) - + (minutes * SecondsInMinute) - + seconds) - nanoSeconds: nanos ! Item was changed: ----- Method: Duration>>asMilliSeconds (in category 'squeak protocol') ----- asMilliSeconds + nanos = 0 ifTrue: [ ^seconds * 1000 ]. + ^nanos // 1000000 + (seconds * 1000)! - - ^ ((seconds * NanosInSecond) + nanos) // (10 raisedToInteger: 6)! Item was changed: ----- Method: Duration>>asNanoSeconds (in category 'squeak protocol') ----- asNanoSeconds + ^seconds * NanosInSecond + nanos! - ^ (seconds * NanosInSecond) + nanos! Item was changed: ----- Method: Float>>adaptToFraction:andCompare: (in category 'converting') ----- adaptToFraction: rcvr andCompare: selector "If I am involved in comparison with a Fraction, convert myself to a Fraction. This way, no bit is lost and comparison is exact." + self isFinite ifFalse: [ + selector == #= ifTrue: [ ^false ]. + selector == #~= ifTrue: [ ^true ]. + (selector == #< or: [ selector == #'<=' ]) + ifTrue: [ ^self >= 0.0]. + (selector == #> or: [ selector == #'>=' ]) + ifTrue: [ ^0.0 >= self ]. + ^self error: 'unknow comparison selector' ]. - self isFinite - ifFalse: [ - selector == #= ifTrue: [^false]. - selector == #~= ifTrue: [^true]. - self isNaN ifTrue: [^ false]. - (selector = #< or: [selector = #'<=']) - ifTrue: [^ self positive]. - (selector = #> or: [selector = #'>=']) - ifTrue: [^ self positive not]. - ^self error: 'unknow comparison selector']. "Try to avoid asTrueFraction because it can cost" rcvr isAnExactFloat ifTrue: [^rcvr asExactFloat perform: selector with: self]. selector == #= ifTrue: [^false]. selector == #~= ifTrue: [^true]. ^ rcvr perform: selector with: self asTrueFraction! Item was changed: ----- Method: Float>>adaptToInteger:andCompare: (in category 'converting') ----- adaptToInteger: rcvr andCompare: selector "If I am involved in comparison with an Integer, convert myself to a Fraction. This way, no bit is lost and comparison is exact." + self isFinite ifFalse: [ + selector == #= ifTrue: [ ^false ]. + selector == #~= ifTrue: [ ^true ]. + (selector == #< or: [ selector == #'<=' ]) + ifTrue: [ ^self >= 0.0 ]. + (selector == #> or: [ selector == #'>=' ]) + ifTrue: [ ^0.0 >= self ]. + ^self error: 'unknow comparison selector']. - self isFinite - ifFalse: [ - selector == #= ifTrue: [^false]. - selector == #~= ifTrue: [^true]. - self isNaN ifTrue: [^ false]. - (selector = #< or: [selector = #'<=']) - ifTrue: [^ self positive]. - (selector = #> or: [selector = #'>=']) - ifTrue: [^ self positive not]. - ^self error: 'unknow comparison selector']. "Try to avoid asTrueFraction because it can cost" selector == #= ifTrue: [ self fractionPart = 0.0 ifFalse: [^false]]. selector == #~= ifTrue: [ self fractionPart = 0.0 ifFalse: [^true]]. rcvr isAnExactFloat ifTrue: [^rcvr asExactFloat perform: selector with: self]. selector == #= ifTrue: [^false]. selector == #~= ifTrue: [^true]. ^ rcvr perform: selector with: self asTrueFraction! Item was changed: ----- Method: Float>>adaptToScaledDecimal:andCompare: (in category 'converting') ----- adaptToScaledDecimal: rcvr andCompare: selector "If I am involved in comparison with a scaled Decimal, convert myself to a Fraction. This way, no bit is lost and comparison is exact." + self isFinite ifFalse: [ + selector == #= ifTrue: [^false]. + selector == #~= ifTrue: [^true]. + (selector == #< or: [ selector == #'<=' ]) + ifTrue: [ ^self >= 0.0 ]. + (selector == #> or: [ selector == #'>=' ]) + ifTrue: [ ^0.0 >= self ]. + ^self error: 'unknow comparison selector' ]. - self isFinite - ifFalse: [ - selector == #= ifTrue: [^false]. - selector == #~= ifTrue: [^true]. - self isNaN ifTrue: [^ false]. - (selector = #< or: [selector = #'<=']) - ifTrue: [^ self positive]. - (selector = #> or: [selector = #'>=']) - ifTrue: [^ self positive not]. - ^self error: 'unknow comparison selector']. "Try to avoid asTrueFraction because it can cost" rcvr isAnExactFloat ifTrue: [^rcvr asExactFloat perform: selector with: self]. selector == #= ifTrue: [^false]. selector == #~= ifTrue: [^true]. ^ rcvr perform: selector with: self asTrueFraction! |
Free forum by Nabble | Edit this page |