summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2020-12-08 23:19:03 -0500
committer AJR <ajrhacker@users.noreply.github.com>2020-12-08 23:19:30 -0500
commit09d755e44e8aab12925b82dd6bade7c6e09beaa9 (patch)
tree91f839ff13ad58453cd814c8fb3dd4c6f2c23975
parentc22cb17f326b4939d8ff4219410909e32e70ab86 (diff)
debug/textbuf.cpp: Another obvious use for std::string_view
-rw-r--r--src/emu/debug/debugcon.cpp4
-rw-r--r--src/emu/debug/textbuf.cpp4
-rw-r--r--src/emu/debug/textbuf.h9
3 files changed, 6 insertions, 11 deletions
diff --git a/src/emu/debug/debugcon.cpp b/src/emu/debug/debugcon.cpp
index 8bce3a26668..a5a5062fdbe 100644
--- a/src/emu/debug/debugcon.cpp
+++ b/src/emu/debug/debugcon.cpp
@@ -158,9 +158,9 @@ void debugger_console::execute_condump(int ref, const std::vector<std::string>&
return;
}
- for (auto line_info : text_buffer_lines(*m_console_textbuf))
+ for (std::string_view line_info : text_buffer_lines(*m_console_textbuf))
{
- fwrite(line_info.text, sizeof(char), line_info.length, f);
+ fwrite(line_info.data(), sizeof(char), line_info.length(), f);
fputc('\n', f);
}
diff --git a/src/emu/debug/textbuf.cpp b/src/emu/debug/textbuf.cpp
index ab7bf6505b3..9290577bece 100644
--- a/src/emu/debug/textbuf.cpp
+++ b/src/emu/debug/textbuf.cpp
@@ -305,7 +305,7 @@ const char *text_buffer_get_seqnum_line(text_buffer const &text, u32 seqnum)
Gets the line that the iterator currently points to.
-----------------------------------------------------------------------*/
-text_buffer_line text_buffer_lines::text_buffer_line_iterator::operator*() const
+std::string_view text_buffer_lines::text_buffer_line_iterator::operator*() const
{
char const *const line = &m_buffer.buffer[m_buffer.lineoffs[m_lineptr]];
@@ -321,7 +321,7 @@ text_buffer_line text_buffer_lines::text_buffer_line_iterator::operator*() const
if (difference < 0)
difference += m_buffer.bufsize;
- return text_buffer_line{ line, size_t(difference) };
+ return std::string_view{ line, size_t(difference) };
}
/*---------------------------------------------------------------------
diff --git a/src/emu/debug/textbuf.h b/src/emu/debug/textbuf.h
index 20ad94139bb..5e6bb444596 100644
--- a/src/emu/debug/textbuf.h
+++ b/src/emu/debug/textbuf.h
@@ -12,6 +12,7 @@
#define MAME_EMU_DEBUG_TEXTBUF_H
#include <memory>
+#include <string_view>
#include "emucore.h"
@@ -22,12 +23,6 @@
struct text_buffer;
-struct text_buffer_line
-{
- const char *text;
- size_t length;
-};
-
// helper class for iterating over the lines of a text_buffer
class text_buffer_lines
{
@@ -49,7 +44,7 @@ public:
}
// technically this isn't a valid forward iterator, because operator * doesn't return a reference
- text_buffer_line operator*() const;
+ std::string_view operator*() const;
text_buffer_line_iterator &operator++();
bool operator!=(const text_buffer_line_iterator& rhs)