summaryrefslogtreecommitdiff
path: root/core/fpdfdoc/cpdf_filespec.cpp
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2017-08-15 10:37:59 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-08-15 15:03:10 +0000
commit8a1758bf11c2d741e0cddc761b1dd2cdf564db93 (patch)
tree82cbafc46f574a05ae0c1d1d3d7f9ebde6cb932d /core/fpdfdoc/cpdf_filespec.cpp
parent171cb27a720036c48ae3a6176084e880742af0a9 (diff)
downloadpdfium-8a1758bf11c2d741e0cddc761b1dd2cdf564db93.tar.xz
Remove GetAt from string classes
This method duplicates the behaviour of the const [] operator and doesn't offer any additional safety. Folding them into one implementation. SetAt is retained, since implementing the non-const [] operator to replace SetAt has potential performance concerns. Specifically many non-obvious cases of reading an element using [] will cause a realloc & copy. BUG=pdfium:860 Change-Id: I3ef5e5e5a15376f040256b646eb0d90636e24b67 Reviewed-on: https://pdfium-review.googlesource.com/10870 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfdoc/cpdf_filespec.cpp')
-rw-r--r--core/fpdfdoc/cpdf_filespec.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/core/fpdfdoc/cpdf_filespec.cpp b/core/fpdfdoc/cpdf_filespec.cpp
index 5ef6f466c5..e34f54e4e1 100644
--- a/core/fpdfdoc/cpdf_filespec.cpp
+++ b/core/fpdfdoc/cpdf_filespec.cpp
@@ -69,13 +69,13 @@ CFX_WideString CPDF_FileSpec::DecodeFileName(const CFX_WideString& filepath) {
return ChangeSlashToPlatform(filepath.c_str());
#elif _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
- if (filepath.GetAt(0) != L'/')
+ if (filepath[0] != L'/')
return ChangeSlashToPlatform(filepath.c_str());
- if (filepath.GetAt(1) == L'/')
+ if (filepath[1] == L'/')
return ChangeSlashToPlatform(filepath.c_str() + 1);
- if (filepath.GetAt(2) == L'/') {
+ if (filepath[2] == L'/') {
CFX_WideString result;
- result += filepath.GetAt(1);
+ result += filepath[1];
result += L':';
result += ChangeSlashToPlatform(filepath.c_str() + 2);
return result;
@@ -158,19 +158,19 @@ CFX_WideString CPDF_FileSpec::EncodeFileName(const CFX_WideString& filepath) {
return CFX_WideString();
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
- if (filepath.GetAt(1) == L':') {
+ if (filepath[1] == L':') {
CFX_WideString result(L'/');
- result += filepath.GetAt(0);
- if (filepath.GetAt(2) != L'\\')
+ result += filepath[0];
+ if (filepath[2] != L'\\')
result += L'/';
result += ChangeSlashToPDF(filepath.c_str() + 2);
return result;
}
- if (filepath.GetAt(0) == L'\\' && filepath.GetAt(1) == L'\\')
+ if (filepath[0] == L'\\' && filepath[1] == L'\\')
return ChangeSlashToPDF(filepath.c_str() + 1);
- if (filepath.GetAt(0) == L'\\')
+ if (filepath[0] == L'\\')
return L'/' + ChangeSlashToPDF(filepath.c_str());
return ChangeSlashToPDF(filepath.c_str());
#elif _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_