forked from Imagelibrary/binutils-gdb
gdb: Use std::string_view instead of gdb::string_view
Given that GDB now requires a C++17, replace all uses of gdb::string_view with std::string_view. This change has mostly been done automatically: - gdb::string_view -> std::string_view - #include "gdbsupport/gdb_string_view.h" -> #include <string_view> One things which got brought up during review is that gdb::stging_view does support being built from "nullptr" while std::sting_view does not. Two places are manually adjusted to account for this difference: gdb/tui/tui-io.c:tui_getc_1 and gdbsupport/format.h:format_piece::format_piece. The above automatic change transformed "gdb::to_string (const gdb::string_view &)" into "gdb::to_string (const std::string_view &)". The various direct users of this function are now explicitly including "gdbsupport/gdb_string_view.h". A later patch will remove the users of gdb::to_string. The implementation and tests of gdb::string_view are unchanged, they will be removed in a following patch. Change-Id: Ibb806a7e9c79eb16a55c87c6e41ad396fecf0207 Approved-By: Tom Tromey <tom@tromey.com> Approved-By: Pedro Alves <pedro@palves.net>
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
#include "gdbsupport/gdb_unique_ptr.h"
|
||||
#include "gdbsupport/array-view.h"
|
||||
#include "poison.h"
|
||||
#include "gdb_string_view.h"
|
||||
#include <string_view>
|
||||
|
||||
#if defined HAVE_LIBXXHASH
|
||||
# include <xxhash.h>
|
||||
@@ -94,7 +94,7 @@ extern const char *safe_strerror (int);
|
||||
true if the start of STRING matches PATTERN, false otherwise. */
|
||||
|
||||
static inline bool
|
||||
startswith (gdb::string_view string, gdb::string_view pattern)
|
||||
startswith (std::string_view string, std::string_view pattern)
|
||||
{
|
||||
return (string.length () >= pattern.length ()
|
||||
&& strncmp (string.data (), pattern.data (), pattern.length ()) == 0);
|
||||
@@ -228,7 +228,7 @@ fast_hash (const void *ptr, size_t len, unsigned int start_value = 0)
|
||||
namespace gdb
|
||||
{
|
||||
|
||||
/* Hash type for gdb::string_view.
|
||||
/* Hash type for std::string_view.
|
||||
|
||||
Even after we switch to C++17 and dump our string_view implementation, we
|
||||
might want to keep this hash implementation if it's faster than std::hash
|
||||
@@ -236,7 +236,7 @@ namespace gdb
|
||||
|
||||
struct string_view_hash
|
||||
{
|
||||
std::size_t operator() (gdb::string_view view) const
|
||||
std::size_t operator() (std::string_view view) const
|
||||
{ return fast_hash (view.data (), view.length ()); }
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user