Dave Hylands
9f76dcd682
py: Prevent many extra vstr allocations.
...
I checked the entire codebase, and every place that vstr_init_len
was called, there was a call to mp_obj_new_str_from_vstr after it.
mp_obj_new_str_from_vstr always tries to reallocate a new buffer
1 byte larger than the original to store the terminating null
character.
In many cases, if we allocated the initial buffer to be 1 byte
longer, we can prevent this extra allocation, and just reuse
the originally allocated buffer.
Asking to read 256 bytes and only getting 100 will still cause
the extra allocation, but if you ask to read 256 and get 256
then the extra allocation will be optimized away.
Yes - the reallocation is optimized in the heap to try and reuse
the buffer if it can, but it takes quite a few cycles to figure
this out.
Note by Damien: vstr_init_len should now be considered as a
string-init convenience function and used only when creating
null-terminated objects.
2015-07-06 17:29:27 +01:00
..
2015-04-16 14:30:16 +00:00
2015-06-04 14:00:29 +00:00
2015-06-04 14:00:29 +00:00
2015-04-07 22:43:28 +01:00
2015-04-07 22:43:28 +01:00
2015-06-04 14:00:29 +00:00
2015-06-04 14:00:29 +00:00
2015-06-04 14:00:29 +00:00
2015-06-04 14:00:29 +00:00
2015-06-25 14:42:13 +00:00
2015-04-16 14:30:16 +00:00
2015-04-03 00:03:07 +03:00
2015-05-17 18:12:19 +01:00
2015-05-17 18:12:19 +01:00
2015-05-04 16:53:52 +03:00
2015-02-15 00:02:27 +00:00
2015-06-29 00:26:45 +03:00
2015-06-25 14:42:13 +00:00
2015-02-07 18:33:58 +00:00
2015-06-25 14:42:13 +00:00
2015-06-25 14:42:13 +00:00
2015-03-26 16:52:45 +00:00
2015-06-25 14:42:13 +00:00
2015-04-07 22:43:28 +01:00
2015-04-07 22:43:28 +01:00
2015-04-19 15:47:05 +01:00
2015-06-25 14:42:13 +00:00
2015-05-17 21:47:11 +01:00
2015-05-17 21:47:11 +01:00
2015-05-31 23:02:04 +03:00
2015-01-20 11:52:12 +02:00
2015-04-16 14:30:16 +00:00
2015-01-07 20:33:00 +00:00
2015-04-21 16:43:18 +00:00
2015-06-22 17:40:12 +01:00
2015-06-04 23:42:45 +01:00
2015-02-27 09:34:51 +00:00
2015-06-04 23:42:45 +01:00
2015-05-30 23:11:16 +01:00
2015-05-30 23:11:16 +01:00
2015-03-03 21:23:13 +00:00
2015-05-12 22:46:02 +01:00
2015-05-20 09:29:22 +01:00
2014-06-07 13:14:45 +01:00
2015-05-06 15:34:33 +03:00
2015-01-01 20:32:09 +00:00
2015-06-13 23:36:30 +01:00
2015-02-02 12:52:14 +00:00
2015-03-20 17:26:10 +00:00
2015-02-07 17:24:10 +00:00
2015-02-15 13:17:11 +00:00
2015-06-13 22:35:25 +01:00
2015-04-16 14:30:16 +00:00
2015-07-05 22:44:14 +03:00
2015-04-28 23:52:36 +01:00
2015-07-02 11:53:08 +02:00
2015-05-28 14:22:12 +00:00
2015-05-28 14:22:12 +00:00
2015-01-07 20:33:00 +00:00
2015-04-25 03:49:23 +03:00
2015-04-25 23:51:14 +01:00
2015-04-25 23:16:39 +01:00
2015-06-25 14:42:13 +00:00
2015-03-03 14:34:40 +00:00
2015-01-07 20:33:00 +00:00
2015-01-07 20:33:00 +00:00
2015-01-08 16:24:44 +00:00
2015-01-07 20:33:00 +00:00
2015-01-07 20:33:00 +00:00
2015-05-12 23:05:53 +01:00
2015-07-02 11:53:08 +02:00
2015-07-02 16:26:57 +01:00
2015-04-29 00:17:48 +01:00
2015-05-12 22:46:02 +01:00
2015-04-16 14:30:16 +00:00
2015-04-16 14:30:16 +00:00
2015-04-16 14:30:16 +00:00
2015-05-17 21:47:11 +01:00
2015-04-16 14:30:16 +00:00
2015-04-06 23:51:29 +03:00
2015-07-02 11:53:08 +02:00
2015-02-27 00:36:39 +00:00
2015-01-20 14:11:27 +00:00
2015-06-13 23:36:30 +01:00
2015-06-08 22:07:27 +01:00
2015-01-01 20:32:09 +00:00
2015-05-11 23:57:42 +01:00
2015-01-01 20:32:09 +00:00
2015-04-04 15:53:11 +01:00
2015-05-12 22:46:02 +01:00
2015-06-13 23:38:28 +01:00
2015-05-12 22:46:02 +01:00
2015-04-25 23:16:39 +01:00
2015-04-16 14:30:16 +00:00
2015-02-27 00:36:39 +00:00
2015-01-20 14:11:27 +00:00
2015-05-04 16:53:52 +03:00
2015-01-01 20:32:09 +00:00
2015-04-21 14:14:24 +00:00
2015-05-12 22:46:02 +01:00
2015-05-17 17:48:47 +01:00
2015-01-20 12:47:20 +00:00
2015-04-16 14:30:16 +00:00
2015-04-07 00:17:11 +03:00
2015-04-16 14:30:16 +00:00
2015-05-05 22:18:07 +03:00
2015-05-05 22:18:07 +03:00
2015-07-06 17:29:27 +01:00
2015-04-16 14:30:16 +00:00
2015-04-16 14:30:16 +00:00
2015-05-17 16:44:24 +01:00
2015-05-12 22:46:02 +01:00
2015-04-21 14:14:24 +00:00
2015-06-13 23:36:30 +01:00
2015-05-04 11:08:40 +01:00
2015-01-20 12:47:20 +00:00
2015-01-01 20:32:09 +00:00
2015-04-21 16:43:18 +00:00
2015-02-13 02:29:46 +00:00
2015-06-23 16:08:51 +00:00
2015-02-08 01:57:40 +00:00
2015-02-08 01:57:40 +00:00
2015-01-01 20:32:09 +00:00
2015-06-11 11:08:39 +03:00
2015-04-16 14:30:16 +00:00
2015-04-09 15:29:54 +00:00
2015-07-04 12:26:52 +03:00
2015-07-06 14:00:09 +01:00
2015-04-29 00:46:26 +01:00
2015-06-25 14:42:13 +00:00
2015-06-27 00:40:21 +03:00
2015-06-25 14:42:13 +00:00
2015-01-01 20:32:09 +00:00
2015-01-01 20:32:09 +00:00
2015-01-20 12:47:20 +00:00
2015-06-25 14:42:13 +00:00
2015-01-01 20:32:09 +00:00
2015-04-03 14:11:13 +01:00
2015-04-03 00:26:47 +03:00
2015-01-01 20:32:09 +00:00
2015-05-12 23:05:53 +01:00
2015-01-01 20:32:09 +00:00
2015-05-20 09:31:22 +01:00
2015-01-01 20:32:09 +00:00
2015-06-25 14:42:13 +00:00
2015-06-25 14:42:13 +00:00
2015-07-06 17:29:27 +01:00
2015-04-16 14:30:16 +00:00