mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Merge pull request #106039 from Ivorforce/cowdata-reserve-exact
Add `reserve_exact` to `CowData`, and change growth factor to 1.5x
This commit is contained in:
commit
6bfcfd1d33
4 changed files with 78 additions and 82 deletions
|
|
@ -569,6 +569,7 @@ Vector<uint8_t> FileAccess::get_buffer(int64_t p_length) const {
|
|||
return data;
|
||||
}
|
||||
|
||||
data.reserve_exact(p_length);
|
||||
Error err = data.resize(p_length);
|
||||
ERR_FAIL_COND_V_MSG(err != OK, data, vformat("Can't resize data to %d elements.", p_length));
|
||||
|
||||
|
|
@ -863,6 +864,7 @@ Vector<uint8_t> FileAccess::get_file_as_bytes(const String &p_path, Error *r_err
|
|||
ERR_FAIL_V_MSG(Vector<uint8_t>(), vformat("Can't open file from path '%s'.", String(p_path)));
|
||||
}
|
||||
Vector<uint8_t> data;
|
||||
data.reserve_exact(f->get_length());
|
||||
data.resize(f->get_length());
|
||||
f->get_buffer(data.ptrw(), data.size());
|
||||
return data;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue