[webkit-changes] [WebKit/WebKit] c6ae14: Rename StringView::empty() to emptyStringView()
Myles C. Maxfield
noreply at github.com
Mon Jun 26 10:54:27 PDT 2023
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: c6ae14a037dce326312ed56920059895f06040d1
https://github.com/WebKit/WebKit/commit/c6ae14a037dce326312ed56920059895f06040d1
Author: Myles C. Maxfield <mmaxfield at apple.com>
Date: 2023-06-26 (Mon, 26 Jun 2023)
Changed paths:
M Source/WTF/wtf/text/StringView.h
M Tools/TestWebKitAPI/Tests/WTF/StringView.cpp
Log Message:
-----------
Rename StringView::empty() to emptyStringView()
https://bugs.webkit.org/show_bug.cgi?id=258383
rdar://111135973
Reviewed by Andy Estes.
There are 4 reasons for this:
1. It's too easy to write empty() when you mean isEmpty(). This is particularly
bad because StringViews have an operator bool, so it's totally legal to
write if (myStringView.empty()) but it doesn't mean what it looks like it
means
2. empty() is a verb! But the function doesn't empty out the contents of the
string.
3. It matches emptyString()
4. No one is using it.
This patch doesn't apply the same treatment to StringImpl::empty(), because that's
more complicated and used much more often.
* Source/WTF/wtf/text/StringView.h:
(WTF::nullStringView):
(WTF::emptyStringView):
(WTF::StringView::substring const):
(WTF::StringView::trim const):
(WTF::StringView::empty): Deleted.
* Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:
(TestWebKitAPI::TEST):
Canonical link: https://commits.webkit.org/265521@main
More information about the webkit-changes
mailing list