aboutsummaryrefslogtreecommitdiff
path: root/py/vstr.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-01-21 19:14:25 +0000
committerDamien George <damien.p.george@gmail.com>2015-01-21 23:17:27 +0000
commit0b9ee86133a2a0524691c6cdac209dbfcb3bf116 (patch)
treee17f1f8c26b2d92991a8481ba5d2fc0649a8c6ce /py/vstr.c
parent2e526ff1a15cfe50aa46fe5611d3160b2a854f49 (diff)
py: Add mp_obj_new_str_from_vstr, and use it where relevant.
This patch allows to reuse vstr memory when creating str/bytes object. This improves memory usage. Also saves code ROM: 128 bytes on stmhal, 92 bytes on bare-arm, and 88 bytes on unix x64.
Diffstat (limited to 'py/vstr.c')
-rw-r--r--py/vstr.c20
1 files changed, 0 insertions, 20 deletions
diff --git a/py/vstr.c b/py/vstr.c
index 1f9f13637..6856cfe39 100644
--- a/py/vstr.c
+++ b/py/vstr.c
@@ -136,26 +136,6 @@ char *vstr_extend(vstr_t *vstr, size_t size) {
return p;
}
-// Shrink vstr to be given size
-bool vstr_set_size(vstr_t *vstr, size_t size) {
- if (vstr->fixed_buf) {
- return false;
- }
- char *new_buf = m_renew(char, vstr->buf, vstr->alloc, size);
- if (new_buf == NULL) {
- vstr->had_error = true;
- return false;
- }
- vstr->buf = new_buf;
- vstr->alloc = vstr->len = size;
- return true;
-}
-
-// Shrink vstr allocation to its actual length
-bool vstr_shrink(vstr_t *vstr) {
- return vstr_set_size(vstr, vstr->len);
-}
-
STATIC bool vstr_ensure_extra(vstr_t *vstr, size_t size) {
if (vstr->len + size + 1 > vstr->alloc) {
if (vstr->fixed_buf) {