Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 016beb85 authored by Elliott Hughes's avatar Elliott Hughes
Browse files

Remove String16::makeLower().

If you need to do a case transformation for a Unicode string, you need
to use icu4c. This only worked for ASCII, which is just silly. Luckily
it doesn't seem to be used anywhere.

Test: treehugger
Change-Id: I4a864823ec35a0b57b50909587cc3efac3f531a7
Merged-In: I4a864823ec35a0b57b50909587cc3efac3f531a7
parent 99037347
Loading
Loading
Loading
Loading
+0 −22
Original line number Diff line number Diff line
@@ -390,28 +390,6 @@ size_t String16::staticStringSize() const {
    return static_cast<size_t>(*(p - 1));
}

status_t String16::makeLower()
{
    const size_t N = size();
    const char16_t* str = string();
    char16_t* edited = nullptr;
    for (size_t i=0; i<N; i++) {
        const char16_t v = str[i];
        if (v >= 'A' && v <= 'Z') {
            if (!edited) {
                SharedBuffer* buf = static_cast<SharedBuffer*>(edit());
                if (!buf) {
                    return NO_MEMORY;
                }
                edited = (char16_t*)buf->data();
                mString = str = edited;
            }
            edited[i] = tolower((char)v);
        }
    }
    return OK;
}

status_t String16::replaceAll(char16_t replaceThis, char16_t withThis)
{
    const size_t N = size();
+0 −5
Original line number Diff line number Diff line
@@ -34,11 +34,6 @@ std::vector<std::function<void(FuzzedDataProvider&, android::String16, android::
                    str1.size();
                }),

                // Casing
                ([](FuzzedDataProvider&, android::String16 str1, android::String16) -> void {
                    str1.makeLower();
                }),

                // Comparison
                ([](FuzzedDataProvider&, android::String16 str1, android::String16 str2) -> void {
                    str1.startsWith(str2);
+0 −15
Original line number Diff line number Diff line
@@ -97,13 +97,6 @@ TEST(String16Test, Remove) {
    EXPECT_STR16EQ(u" m", tmp);
}

TEST(String16Test, MakeLower) {
    String16 tmp("Verify Me!");
    tmp.makeLower();
    EXPECT_EQ(10U, tmp.size());
    EXPECT_STR16EQ(u"verify me!", tmp);
}

TEST(String16Test, ReplaceAll) {
    String16 tmp("Verify verify Verify");
    tmp.replaceAll(u'r', u'!');
@@ -176,14 +169,6 @@ TEST(String16Test, StaticStringRemove) {
    EXPECT_FALSE(tmp.isStaticString());
}

TEST(String16Test, StaticStringMakeLower) {
    StaticString16 tmp(u"Verify me!");
    tmp.makeLower();
    EXPECT_EQ(10U, tmp.size());
    EXPECT_STR16EQ(u"verify me!", tmp);
    EXPECT_FALSE(tmp.isStaticString());
}

TEST(String16Test, StaticStringReplaceAll) {
    StaticString16 tmp(u"Verify verify Verify");
    tmp.replaceAll(u'r', u'!');
+0 −2
Original line number Diff line number Diff line
@@ -85,8 +85,6 @@ public:

            bool                contains(const char16_t* chrs) const;

            status_t            makeLower();

            status_t            replaceAll(char16_t replaceThis,
                                           char16_t withThis);