summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2020-12-22 08:18:47 -0500
committer AJR <ajrhacker@users.noreply.github.com>2020-12-22 08:18:47 -0500
commit735e7d5b2a7b321965c5ccd7c226b17e2e5ff8cb (patch)
tree44d83d49a91364054c0c75303206ba053b221e00 /src/lib
parentbf4338f9a889748a94980146d105c4872921af0e (diff)
util/png: Use std::string_view internally in another function
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/util/png.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/lib/util/png.cpp b/src/lib/util/png.cpp
index 9a9edecd8df..d03f993a7be 100644
--- a/src/lib/util/png.cpp
+++ b/src/lib/util/png.cpp
@@ -1175,30 +1175,28 @@ static png_error write_png_stream(core_file &fp, png_info &pnginfo, const bitmap
std::uint8_t *dst(&textbuf[0]);
// convert keyword to ISO-8859-1
- char const *const kwend(text.first.c_str() + text.first.length());
- for (char const *src = text.first.c_str(); kwend > src; ++dst)
+ for (std::string_view src = text.first; !src.empty(); ++dst)
{
char32_t ch;
- int const len(uchar_from_utf8(&ch, src, kwend - src));
+ int const len(uchar_from_utf8(&ch, src));
if (0 >= len)
break;
*dst = std::uint8_t(ch);
- src += len;
+ src.remove_prefix(len);
}
// NUL separator between keword and text
*dst++ = 0;
// convert text to ISO-8859-1
- char const *const textend(text.second.c_str() + text.second.length());
- for (char const *src = text.second.c_str(); textend > src; ++dst)
+ for (std::string_view src = text.second; !src.empty(); ++dst)
{
char32_t ch;
- int const len(uchar_from_utf8(&ch, src, textend - src));
+ int const len(uchar_from_utf8(&ch, src));
if (0 >= len)
break;
*dst = std::uint8_t(ch);
- src += len;
+ src.remove_prefix(len);
}
error = write_chunk(fp, &textbuf[0], PNG_CN_tEXt, dst - &textbuf[0]);