Re: Calculate Last Digits
- From: "Steve Gerrard" <mynamehere@xxxxxxxxxxx>
- Date: Sat, 20 Oct 2007 21:12:21 -0700
"Robert Morley" <rmorley@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:O0$wPu4EIHA.280@xxxxxxxxxxxxxxxxxxxxxxx
See possible code improvement, in-line:
For j = 0 To 9
If Cnt(j) > Cnt(max) Then
max = j
End If
This might work faster by adding the following line at this point:
If Cnt(j) >= 3 Then Exit For
(Or use whatever method you prefer to exit the For Loop...personally I avoid
Exit For, as discussed at enormous length in older threads <g>, but this is
the easiest change given the existing code.)
I couldn't get much difference with that, I think it is a wash between extra
testing and sometimes early exiting. It does seem like the excess looping should
be cut out, but I'm not sure it gets any faster if you do a real sort, or
whatever.
- - - - -
I did get a big (3X) boost by switching from strings to longs for the pattern
"map" (edited lines only):
Private Map(10) As Long
.....
Map(1) = 111111
Map(2) = 211110
' etc.
.....
Dim pattern As Long
.....
pattern = pattern * 10 + Cnt(max)
.....
The 211110 etc. patterns work just as well as longs, and the comparisons and
manipulations are much faster.
.
- Follow-Ups:
- Re: Calculate Last Digits
- From: Paul Black
- Re: Calculate Last Digits
- References:
- Calculate Last Digits
- From: Paul Black
- Re: Calculate Last Digits
- From: Robert Morley
- Re: Calculate Last Digits
- From: Robert Morley
- Re: Calculate Last Digits
- From: Steve Gerrard
- Re: Calculate Last Digits
- From: Steve Gerrard
- Re: Calculate Last Digits
- From: Robert Morley
- Calculate Last Digits
- Prev by Date: Re: PDF output
- Next by Date: Re: Displaying Recycle bin true contents in ListView
- Previous by thread: Re: Calculate Last Digits
- Next by thread: Re: Calculate Last Digits
- Index(es):
Relevant Pages
|