From b6b01cb2cbaf6b38736f4dfebb9b6cdc243960f9 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 20 Jun 2018 16:10:13 +0000 Subject: Re-work some more c_str() usage. Many of these are converting ByteString => c_str => ByteStringView, since the ByteStringView ctor is implicit. This is unfortunate, since that involves a strlen() which the ByteString already knows if we use AsStringView() instead. This changed one test result where we can now return the string "\0" instead of "" -- since strlen no longer eats the NUL. This seems consistent, say, with String.fromCharCode(). Change-Id: I17f68d1a1f4b352960208f9148e68ab4c4d78bd2 Reviewed-on: https://pdfium-review.googlesource.com/35590 Reviewed-by: dsinclair Commit-Queue: Tom Sepez --- fxjs/cjs_annot.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'fxjs/cjs_annot.cpp') diff --git a/fxjs/cjs_annot.cpp b/fxjs/cjs_annot.cpp index 8a53ebc048..49db20475a 100644 --- a/fxjs/cjs_annot.cpp +++ b/fxjs/cjs_annot.cpp @@ -81,8 +81,8 @@ CJS_Return CJS_Annot::set_hidden(CJS_Runtime* pRuntime, CJS_Return CJS_Annot::get_name(CJS_Runtime* pRuntime) { if (!m_pAnnot) return CJS_Return(JSMessage::kBadObjectError); - return CJS_Return( - pRuntime->NewString(ToBAAnnot(m_pAnnot.Get())->GetAnnotName().c_str())); + return CJS_Return(pRuntime->NewString( + ToBAAnnot(m_pAnnot.Get())->GetAnnotName().AsStringView())); } CJS_Return CJS_Annot::set_name(CJS_Runtime* pRuntime, v8::Local vp) { @@ -101,8 +101,8 @@ CJS_Return CJS_Annot::get_type(CJS_Runtime* pRuntime) { return CJS_Return(pRuntime->NewString( WideString::FromLocal(CPDF_Annot::AnnotSubtypeToString( ToBAAnnot(m_pAnnot.Get())->GetAnnotSubtype()) - .c_str()) - .c_str())); + .AsStringView()) + .AsStringView())); } CJS_Return CJS_Annot::set_type(CJS_Runtime* pRuntime, v8::Local vp) { -- cgit v1.2.3