From 1e934f6868465bca960f9f13489489ba1d649581 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 11 Apr 2018 21:11:28 +0000 Subject: Remove use of GetBuffer()/ReleaseBuffer() when c_str() is sufficient. Greatly simplify the code which was neither changing allocations nor doing any actual work. Eventually GetBuffer() will return a span, and this makes fewer places to change. Comment AsFPDFWideString() as a place where we may want a redundant copy, and make available outside the .cpp file. Fix one "const" along the way. Change-Id: I187758b69a0ba3501b3622f6c06280793cd5d464 Reviewed-on: https://pdfium-review.googlesource.com/30011 Reviewed-by: dsinclair Commit-Queue: Tom Sepez --- fxjs/cjs_document.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'fxjs') diff --git a/fxjs/cjs_document.cpp b/fxjs/cjs_document.cpp index 83711e1b28..2a36b61a4a 100644 --- a/fxjs/cjs_document.cpp +++ b/fxjs/cjs_document.cpp @@ -942,11 +942,9 @@ CJS_Return CJS_Document::get_document_file_name(CJS_Runtime* pRuntime) { if (wsFilePath[i - 1] == L'\\' || wsFilePath[i - 1] == L'/') break; } + if (i > 0 && i < wsFilePath.GetLength()) + return CJS_Return(pRuntime->NewString(wsFilePath.c_str() + i)); - if (i > 0 && i < wsFilePath.GetLength()) { - return CJS_Return( - pRuntime->NewString(wsFilePath.GetBuffer(wsFilePath.GetLength()) + i)); - } return CJS_Return(pRuntime->NewString(L"")); } -- cgit v1.2.3