- avoid is() / as() coercion from integer -> numeric in field setter
- avoid unnecessary addition
git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/Streamer@68700 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -3,17 +3,21 @@ |
3 | 3 |
from="numeric", to="numeric", by="numeric", length.out="integer"), |
4 | 4 |
contains="Producer", |
5 | 5 |
methods = list( |
6 |
+ initialize = function(..., length.out) { |
|
7 |
+ ## increment length.out to avoid repeated addition |
|
8 |
+ callSuper(..., length.out=as.integer(length.out) + 1L) |
|
9 |
+ }, |
|
6 | 10 |
yield = function() { |
7 | 11 |
if ((from - to) * by > 0) |
8 |
- return(integer()) |
|
9 |
- s <- seq(from, by=by, length.out=length.out + 1L) |
|
10 |
- .self$from <- s[length(s)] |
|
12 |
+ return(numeric()) |
|
13 |
+ s <- seq(from, by=by, length.out=length.out) |
|
14 |
+ from <<- as.numeric(s[length(s)]) |
|
11 | 15 |
s <- s[-length(s)] |
12 | 16 |
s[s <= to] |
13 | 17 |
}, |
14 | 18 |
show = function() { |
15 | 19 |
cat("from:", from, "\nto:", to, "\nby:", by, |
16 |
- "\nlength.out:", length.out, "\n") |
|
20 |
+ "\nlength.out:", length.out - 1L, "\n") |
|
17 | 21 |
})) |
18 | 22 |
|
19 | 23 |
Seq <- |