mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-23 03:06:42 +00:00
Optimize for speed
This commit is contained in:
parent
1333f632b7
commit
138f0fb3ee
@ -2,25 +2,26 @@
|
|||||||
#define _CHAR_STREAM_H_
|
#define _CHAR_STREAM_H_
|
||||||
|
|
||||||
#include <Stream.h>
|
#include <Stream.h>
|
||||||
#include "Arduino.h"
|
|
||||||
|
|
||||||
class CharStream : public Stream {
|
class CharStream : public Stream {
|
||||||
public:
|
public:
|
||||||
CharStream(char * s) : string(s), position(0)
|
CharStream(char * s) : string(s), position(0)
|
||||||
{}
|
{
|
||||||
|
length = strlen(s);
|
||||||
|
}
|
||||||
|
|
||||||
// Stream methods
|
// Stream methods
|
||||||
virtual int available()
|
virtual int available()
|
||||||
{
|
{
|
||||||
return strlen(string) - position;
|
return length - position;
|
||||||
}
|
}
|
||||||
virtual int read()
|
virtual int read()
|
||||||
{
|
{
|
||||||
return position < strlen(string) ? string[position++] : -1;
|
return position < length ? string[position++] : -1;
|
||||||
}
|
}
|
||||||
virtual int peek()
|
virtual int peek()
|
||||||
{
|
{
|
||||||
return position < strlen(string) ? string[position] : -1;
|
return position < length ? string[position] : -1;
|
||||||
}
|
}
|
||||||
virtual void flush(){};
|
virtual void flush(){};
|
||||||
// Print methods
|
// Print methods
|
||||||
|
Loading…
x
Reference in New Issue
Block a user