Skip to content

Commit 5704970

Browse files
Merge pull request #2 from fcladera/master
Events type is bytes, not bytearray
2 parents b5d627e + bde3243 commit 5704970

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/decoder.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,15 @@ void Decoder::decode_bytes(
3232
if (decoder) {
3333
decoder->setTimeBase(timeBase);
3434
decoder->setTimeMultiplier(1); // report in usecs instead of nanoseconds
35-
const size_t bufSize = PyByteArray_GET_SIZE(events.ptr());
36-
// for some reason this returns a bad pointer
37-
// const uint8_t *buf = reinterpret_cast<uint8_t *>(PyByteArray_AsString(events.ptr()));
38-
// TODO(Bernd): avoid the memory copy here
39-
const std::string foo(events); // creates unnecessary copy!
4035
delete cdEvents_; // in case events have not been picked up
4136
cdEvents_ = new std::vector<EventCD>();
4237
delete extTrigEvents_; // in case events have not been picked up
4338
extTrigEvents_ = new std::vector<EventExtTrig>();
4439
// TODO(Bernd): use hack here to avoid initializing the memory
4540
cdEvents_->reserve(maxSizeCD_);
4641
extTrigEvents_->reserve(maxSizeExtTrig_);
47-
const uint8_t * buf = reinterpret_cast<const uint8_t *>(&foo[0]);
48-
decoder->decode(buf, bufSize, this);
42+
const uint8_t * buf = reinterpret_cast<const uint8_t *>(PyBytes_AsString(events.ptr()));
43+
decoder->decode(buf, PyBytes_Size(events.ptr()), this);
4944
}
5045
}
5146

0 commit comments

Comments
 (0)