From: Owen Avery Date: Wed, 2 Aug 2023 20:45:42 +0000 (-0400) Subject: gccrs: Improve byte vector to string conversion X-Git-Tag: basepoints/gcc-15~2202 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=750ac3263c8db064b1d6b3ae33ec6a2036e38bb8;p=thirdparty%2Fgcc.git gccrs: 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 --- diff --git a/gcc/rust/expand/rust-macro-builtins.cc b/gcc/rust/expand/rust-macro-builtins.cc index 718d740b1dc7..b36a46f0affd 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)));