Skip to content

Commit e309d34

Browse files
committed
fix: make take_batch_from_source() InMemory arm unreachable
next_batch() already handles InMemory via zero-copy &data[start..end]. Remove the dead-code .to_vec() clone path that contradicted the documented optimization claim. Addresses review comment from 400Ping.
1 parent 7a856a1 commit e309d34

File tree

1 file changed

+6
-30
lines changed

1 file changed

+6
-30
lines changed

qdp/qdp-core/src/pipeline_runner.rs

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -388,36 +388,12 @@ impl PipelineIterator {
388388
))
389389
}
390390
}
391-
DataSource::InMemory {
392-
data,
393-
cursor,
394-
sample_size,
395-
batches_yielded,
396-
batch_limit,
397-
..
398-
} => {
399-
if *batches_yielded >= *batch_limit {
400-
None
401-
} else {
402-
let remaining = (data.len() - *cursor) / *sample_size;
403-
if remaining == 0 {
404-
None
405-
} else {
406-
let batch_n = remaining.min(self.config.batch_size);
407-
let start = *cursor;
408-
let end = start + batch_n * *sample_size;
409-
*cursor = end;
410-
*batches_yielded += 1;
411-
let slice = data[start..end].to_vec();
412-
Some((
413-
slice,
414-
batch_n,
415-
*sample_size,
416-
self.config.num_qubits as usize,
417-
))
418-
}
419-
}
420-
}
391+
// InMemory is handled directly by next_batch() via zero-copy &data[start..end];
392+
// take_batch_from_source() is only called from the Synthetic/Streaming path.
393+
DataSource::InMemory { .. } => unreachable!(
394+
"InMemory batches are served by next_batch() directly (zero-copy); \
395+
take_batch_from_source() should not be called for InMemory"
396+
),
421397
DataSource::Streaming {
422398
reader,
423399
buffer,

0 commit comments

Comments
 (0)