diff options
author | Owen Avery <powerboat9.gamer@gmail.com> | 2023-08-02 16:45:42 -0400 |
---|---|---|
committer | CohenArthur <arthur.cohen@embecosm.com> | 2023-08-22 12:43:11 +0000 |
commit | ba4db84d492626c95cad491877a5bd7e5cc412e8 (patch) | |
tree | d0aeba214aadad056bb5b2eec0c4f672135621e6 /gcc/rust | |
parent | 8fcbb07fa702ab817fa3dd8cff3a0086e70a6ab7 (diff) | |
download | gcc-ba4db84d492626c95cad491877a5bd7e5cc412e8.zip gcc-ba4db84d492626c95cad491877a5bd7e5cc412e8.tar.gz gcc-ba4db84d492626c95cad491877a5bd7e5cc412e8.tar.bz2 |
Improve byte vector to string conversion
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc
(MacroBuiltin::include_str_handler): Use vector::data.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Diffstat (limited to 'gcc/rust')
-rw-r--r-- | gcc/rust/expand/rust-macro-builtins.cc | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/gcc/rust/expand/rust-macro-builtins.cc b/gcc/rust/expand/rust-macro-builtins.cc index 44eeaac..ecbd6ad 100644 --- a/gcc/rust/expand/rust-macro-builtins.cc +++ b/gcc/rust/expand/rust-macro-builtins.cc @@ -576,10 +576,8 @@ MacroBuiltin::include_str_handler (location_t invoc_locus, if (expect_single) rust_error_at (invoc_locus, "%s was not a valid utf-8 file", target_filename.c_str ()); - else if (!bytes.empty ()) - str = std::string ((const char *) &bytes[0], bytes.size ()); else - return tl::nullopt; + str = std::string ((const char *) bytes.data (), bytes.size ()); auto node = AST::SingleASTNode (make_string (invoc_locus, str)); auto str_tok = make_token (Token::make_string (invoc_locus, std::move (str))); |