mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-06-23 14:45:36 +00:00
refactor: faster chunk & schematic loading
This commit is contained in:
@@ -20,6 +20,8 @@ public:
|
||||
ByteArrayInputStream(std::vector<uint8_t>& buf, unsigned int offset,
|
||||
unsigned int length);
|
||||
ByteArrayInputStream(std::vector<uint8_t>& buf);
|
||||
// takes ownership of the vector
|
||||
ByteArrayInputStream(std::vector<uint8_t>&& buf);
|
||||
virtual ~ByteArrayInputStream();
|
||||
virtual int read();
|
||||
virtual int read(std::vector<uint8_t>& b);
|
||||
@@ -36,4 +38,4 @@ public:
|
||||
mark = 0;
|
||||
pos = 0;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -28,6 +28,11 @@ ByteArrayInputStream::ByteArrayInputStream(std::vector<uint8_t>& buf)
|
||||
this->buf = buf;
|
||||
}
|
||||
|
||||
// 4jcraft: helper function to create a ByteArrayInputStream from a vector of bytes to avoid one copy
|
||||
ByteArrayInputStream::ByteArrayInputStream(std::vector<uint8_t>&& buf)
|
||||
: buf(std::move(buf)), pos(0), count(this->buf.size()), mark(0) {
|
||||
}
|
||||
|
||||
// Reads the next byte of data from this input stream. The value byte is
|
||||
// returned as an int in the range 0 to 255. If no byte is available because the
|
||||
// end of the stream has been reached, the value -1 is returned. This read
|
||||
|
||||
Reference in New Issue
Block a user