[MDEV-20453] add class similar to std::string_view (non owning string reference) Created: 2019-08-30 Updated: 2022-02-03 Resolved: 2022-02-03 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Server, Storage Engine - InnoDB |
| Fix Version/s: | N/A |
| Type: | Task | Priority: | Major |
| Reporter: | Eugene Kosov (Inactive) | Assignee: | Eugene Kosov (Inactive) |
| Resolution: | Won't Do | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Class is basically:
It's intended to replace all naked char * and const std::string:: & in functions arguments. string_view makes code easier to read. Also it has begin(), end() member which allows it's data to be used in range-for loops. https://en.cppreference.com/w/cpp/string/basic_string_view |
| Comments |
| Comment by Marko Mäkelä [ 2020-07-15 ] |
|
It seems that the function fsp_path_to_space_name() is initially accessing one byte before the start of the string, in the first iteration of string_view::rfind() with the default parameter pos=npos, tripping AddressSanitizer in many tests. I reverted the change due to this. Please fix and test with ASAN. |
| Comment by Marko Mäkelä [ 2021-10-01 ] |
|
The originally found issue may have been resolved by I think that there needs to be some measurable benefit from such refactoring. I see that we currently use std::string (and are unnecessarily copying some data) in file_name_t::name and renamed_spaces. We could make those point directly to the redo log parse buffer. The data would only have to be copied at the end of each non-final recv_sys_t::apply() before the underlying buffer would be invalidated by recv_sys_t::free(). In that way, we would avoid copying any file name strings when only one recovery batch is needed. |
| Comment by Marko Mäkelä [ 2022-02-03 ] |
|
I think that this basically already exists as LEX_STRING and LEX_CSTRING. We perhaps should not develop several ways of doing the same thing, and I am afraid that there would be strong opposition if the existing classes were renamed or refactored. |