From 17e54528fe0a2203074f4d086677d14c33cf7253 Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Wed, 2 Aug 2017 16:36:37 -0400 Subject: Remove parameter from GetID All of the call sites for this method used the default value, so it has been removed. This simplifies converting FX_STRSIZE to be unsigned, since the removed parameter was of this type. BUG=pdfium:828 Change-Id: I369285aed561731ab34ec6d30de0d21fb3431492 Reviewed-on: https://pdfium-review.googlesource.com/9891 Reviewed-by: Tom Sepez Commit-Queue: Ryan Harrison --- core/fxcrt/cfx_bytestring.cpp | 3 --- core/fxcrt/cfx_bytestring.h | 2 +- core/fxcrt/cfx_bytestring_unittest.cpp | 18 ------------------ core/fxcrt/cfx_string_c_template.h | 8 ++++---- 4 files changed, 5 insertions(+), 26 deletions(-) diff --git a/core/fxcrt/cfx_bytestring.cpp b/core/fxcrt/cfx_bytestring.cpp index 6cbd15e693..77e0ecd610 100644 --- a/core/fxcrt/cfx_bytestring.cpp +++ b/core/fxcrt/cfx_bytestring.cpp @@ -814,9 +814,6 @@ void CFX_ByteString::TrimLeft() { TrimLeft("\x09\x0a\x0b\x0c\x0d\x20"); } -uint32_t CFX_ByteString::GetID(FX_STRSIZE start_pos) const { - return AsStringC().GetID(start_pos); -} FX_STRSIZE FX_ftoa(float d, char* buf) { buf[0] = '0'; buf[1] = '\0'; diff --git a/core/fxcrt/cfx_bytestring.h b/core/fxcrt/cfx_bytestring.h index df1b8309fc..902d28f300 100644 --- a/core/fxcrt/cfx_bytestring.h +++ b/core/fxcrt/cfx_bytestring.h @@ -155,7 +155,7 @@ class CFX_ByteString { CFX_WideString UTF8Decode() const; - uint32_t GetID(FX_STRSIZE start_pos = 0) const; + uint32_t GetID() const { return AsStringC().GetID(); } #define FXFORMAT_SIGNED 1 #define FXFORMAT_HEX 2 diff --git a/core/fxcrt/cfx_bytestring_unittest.cpp b/core/fxcrt/cfx_bytestring_unittest.cpp index d843afef97..b79a765e20 100644 --- a/core/fxcrt/cfx_bytestring_unittest.cpp +++ b/core/fxcrt/cfx_bytestring_unittest.cpp @@ -835,33 +835,15 @@ TEST(fxcrt, ByteStringCFromVector) { TEST(fxcrt, ByteStringCGetID) { CFX_ByteStringC null_string; EXPECT_EQ(0u, null_string.GetID()); - EXPECT_EQ(0u, null_string.GetID(1)); - EXPECT_EQ(0u, null_string.GetID(-1)); - EXPECT_EQ(0u, null_string.GetID(-1000000)); CFX_ByteStringC empty_string(""); EXPECT_EQ(0u, empty_string.GetID()); - EXPECT_EQ(0u, empty_string.GetID(1)); - EXPECT_EQ(0u, empty_string.GetID(-1)); - EXPECT_EQ(0u, empty_string.GetID(-1000000)); CFX_ByteStringC short_string("ab"); EXPECT_EQ(FXBSTR_ID('a', 'b', 0, 0), short_string.GetID()); - EXPECT_EQ(FXBSTR_ID('b', 0, 0, 0), short_string.GetID(1)); - EXPECT_EQ(0u, short_string.GetID(2)); - EXPECT_EQ(0u, short_string.GetID(-1)); - EXPECT_EQ(0u, short_string.GetID(-1000000)); CFX_ByteStringC longer_string("abcdef"); EXPECT_EQ(FXBSTR_ID('a', 'b', 'c', 'd'), longer_string.GetID()); - EXPECT_EQ(FXBSTR_ID('b', 'c', 'd', 'e'), longer_string.GetID(1)); - EXPECT_EQ(FXBSTR_ID('c', 'd', 'e', 'f'), longer_string.GetID(2)); - EXPECT_EQ(FXBSTR_ID('d', 'e', 'f', 0), longer_string.GetID(3)); - EXPECT_EQ(FXBSTR_ID('e', 'f', 0, 0), longer_string.GetID(4)); - EXPECT_EQ(FXBSTR_ID('f', 0, 0, 0), longer_string.GetID(5)); - EXPECT_EQ(0u, longer_string.GetID(6)); - EXPECT_EQ(0u, longer_string.GetID(-1)); - EXPECT_EQ(0u, longer_string.GetID(-1000000)); } TEST(fxcrt, ByteStringCFind) { diff --git a/core/fxcrt/cfx_string_c_template.h b/core/fxcrt/cfx_string_c_template.h index b87b65991e..6a95a05d45 100644 --- a/core/fxcrt/cfx_string_c_template.h +++ b/core/fxcrt/cfx_string_c_template.h @@ -99,14 +99,14 @@ class CFX_StringCTemplate { return !(*this == other); } - uint32_t GetID(FX_STRSIZE start_pos = 0) const { - if (m_Length == 0 || start_pos < 0 || start_pos >= m_Length) + uint32_t GetID() const { + if (m_Length == 0) return 0; uint32_t strid = 0; - FX_STRSIZE size = std::min(4, m_Length - start_pos); + FX_STRSIZE size = std::min(4, m_Length); for (FX_STRSIZE i = 0; i < size; i++) - strid = strid * 256 + m_Ptr.Get()[start_pos + i]; + strid = strid * 256 + m_Ptr.Get()[i]; return strid << ((4 - size) * 8); } -- cgit v1.2.3