Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

default implementation for buffered Stream.read only reads every second byte #8452

Closed
Assignees
d-a-v
Labels
@INemesisI

Description

@INemesisI

The current Stream::read (uint8_t* buffer, size_t maxLen) provides a standard implementation for writing a stream to a buffer.
It uses the virtual int method Stream::read() to read the stream byte by byte until no more bytes are available.

However, it calls read() twice in each loop. This results in only every 2nd byte actually being read into the destination buffer, as the read() method will always return the next byte in the stream.
At least that is my understanding of how the read() method of streams is supposed to work.

The lines of code involved:

intStream::read (uint8_t* buffer,size_t maxLen)
{
IAMSLOW();
size_t nbread =0;
while (nbread < maxLen &&available())
{
int c =read();
if (c == -1)
break;
buffer[nbread++] =read();
}
return nbread;

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp