Chris Muller uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-cmm.685.mcz ==================== Summary ==================== Name: Kernel-cmm.685 Author: cmm Time: 4 July 2012, 1:47:58.748 pm UUID: 42e3ebd5-8ae7-4231-a98d-c2e676009dc8 Ancestors: Kernel-eem.684 - Inline and then remove DateAndTime class>>#todayAtMilliseconds: and #todayAtNanoSeconds: into #nowWithOffset:. - Eliminate duplicate code in Integer printing methods and deprecate one of the methods. =============== Diff against Kernel-eem.684 =============== Item was changed: ----- Method: DateAndTime class>>nowWithOffset: (in category 'squeak protocol') ----- + nowWithOffset: aDuration - nowWithOffset: aDuration | nanoTicks msm | - nanoTicks := (msm := self milliSecondsSinceMidnight) * 1000000. + "The following usually only executes at system startup." + ^ LastTick < nanoTicks + ifTrue: + [ LastTick := nanoTicks. + self waitForOffsets. + self basicNew + setJdn: DaysSinceEpoch + seconds: msm // 1000 + nano: msm \\ 1000 * 1000000 + offset: aDuration ] + ifFalse: + [ LastTickSemaphore critical: + [ LastTick := LastTick + 1. + self waitForOffsets. + self basicNew + setJdn: DaysSinceEpoch + seconds: LastTick // 1000000000 + nano: LastTick \\ 1000000000 + offset: aDuration ] ] - - (LastTick < nanoTicks) ifTrue: [ - LastTick := nanoTicks. - ^ self todayAtMilliSeconds: msm offset: aDuration]. - - LastTickSemaphore critical: [ - LastTick := LastTick + 1. - ^ self todayAtNanoSeconds: LastTick offset: aDuration] - " [ 10000 timesRepeat: [ self now. ] ] timeToRun / 10000.0 . If calls to DateAndTime-c-#now are within a single millisecond the semaphore code to ensure that (self now <= self now) slows things down considerably by a factor of about 20. The actual speed of a single call to DateAndTime-now in milliseconds is demonstrated by the unguarded method below. [ 100000 timesRepeat: [ self todayAtMilliSeconds: (self milliSecondsSinceMidnight) ] ] timeToRun / 100000.0 . 0.00494 0.00481 0.00492 0.00495 "! Item was removed: - ----- Method: DateAndTime class>>todayAtMilliSeconds: (in category 'squeak protocol') ----- - todayAtMilliSeconds: milliSecondsSinceMidnight - self deprecated: 'Use todayAtMilliSeconds:offset:.'. - ^ self - todayAtMilliSeconds: milliSecondsSinceMidnight - offset: self localOffset! Item was removed: - ----- Method: DateAndTime class>>todayAtMilliSeconds:offset: (in category 'squeak protocol') ----- - todayAtMilliSeconds: milliSecondsSinceMidnight offset: aDuration - - "This is usually only during system startup..." - self waitForOffsets. - - ^ self basicNew - setJdn: DaysSinceEpoch - seconds: (milliSecondsSinceMidnight // 1000) - nano: (milliSecondsSinceMidnight \\ 1000 * 1000000 ) - offset: aDuration - - " - [ 100000 timesRepeat: [ self fromMilliSeconds: self milliSecondsSinceMidnight. ] ] timeToRun. - "! Item was removed: - ----- Method: DateAndTime class>>todayAtNanoSeconds: (in category 'squeak protocol') ----- - todayAtNanoSeconds: nanoSecondsSinceMidnight - self deprecated: 'Use todayAtNanoSeconds:offset:.'. - self - todayAtNanoSeconds: nanoSecondsSinceMidnight - offset: self localOffset! Item was removed: - ----- Method: DateAndTime class>>todayAtNanoSeconds:offset: (in category 'squeak protocol') ----- - todayAtNanoSeconds: nanoSecondsSinceMidnight offset: aDuration - - "This is usually only during system startup..." - self waitForOffsets. - - ^ self basicNew - setJdn: DaysSinceEpoch - seconds: (nanoSecondsSinceMidnight // 1000000000) - nano: (nanoSecondsSinceMidnight \\ 1000000000 ) - offset: self localOffset - ! Item was changed: ----- Method: Integer>>asStringWithCommas (in category 'printing') ----- asStringWithCommas "123456789 asStringWithCommas" "-123456789 asStringWithCommas" + ^ self asStringWithCommasSigned: false! - | digits | - digits := self abs printString. - ^ String streamContents: - [:strm | - self sign = -1 ifTrue: [strm nextPut: $-]. - 1 to: digits size do: - [:i | strm nextPut: (digits at: i). - (i < digits size and: [(i - digits size) \\ 3 = 0]) - ifTrue: [strm nextPut: $,]]]! Item was changed: ----- Method: Integer>>asStringWithCommasSigned (in category 'printing') ----- asStringWithCommasSigned "123456789 asStringWithCommasSigned" "-123456789 asStringWithCommasSigned" | digits | + self deprecated: 'Use #asStringWithCommasSigned:'. digits := self abs printString. ^ String streamContents: [:strm | self sign = -1 ifTrue: [strm nextPut: $-] ifFalse:[strm nextPut: $+]. 1 to: digits size do: [:i | strm nextPut: (digits at: i). (i < digits size and: [(i - digits size) \\ 3 = 0]) ifTrue: [strm nextPut: $,]]]! Item was added: + ----- Method: Integer>>asStringWithCommasSigned: (in category 'printing') ----- + asStringWithCommasSigned: aBoolean + "123456789 asStringWithCommasSigned: true" + "-123456789 asStringWithCommasSigned: false" + | digits | + digits := self abs printString. + ^ String streamContents: + [:strm | + self sign = -1 ifTrue: [strm nextPut: $-] ifFalse: [aBoolean ifTrue: [strm nextPut: $+]]. + 1 to: digits size do: + [:i | strm nextPut: (digits at: i). + (i < digits size and: [(i - digits size) \\ 3 = 0]) + ifTrue: [strm nextPut: $,]]]! |
Free forum by Nabble | Edit this page |