[Webkit-unassigned] [Bug 148388] We should also store the time information for recent searches

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Sep 17 15:07:51 PDT 2015


https://bugs.webkit.org/show_bug.cgi?id=148388

--- Comment #23 from Zach Li <zacharyli323 at gmail.com> ---
(In reply to comment #17)
> Comment on attachment 261270 [details]
> Patch v3
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=261270&action=review
> 
> > Source/WebCore/platform/SearchPopupMenu.h:36
> > +    virtual void saveRecentSearches(const AtomicString& name, const Vector<std::pair<String, double>>& searchItems) = 0;
> > +    virtual void loadRecentSearches(const AtomicString& name, Vector<std::pair<String, double>>& searchItems) = 0;
> 
> This interface is confusing. Nothing about std::pair<String, double>
> indicates to me that one element is the search string and the other is a
> time. We’d probably be better off with a struct so we can name the two
> members.

That sounds a lot better. I will use a struct to represent the recent search item.

> 
> Also, I suggest for new code we use std::chrono. Instead of double we would
> use std::chrono::time_point<std::chrono::system_clock>.
> 
> > Source/WebCore/rendering/RenderSearchField.cpp:95
> > +    int size = static_cast<int>(m_recentSearches.size());
> > +    for (int i = size - 1; i >= 0; --i) {
> > +        if (m_recentSearches[i].first == value)
> > +            m_recentSearches.remove(i);
> > +    }
> 
> This is really ugly, especially the static_cast<int> part. We should try to
> do a little better.

Totally agreed. I think removeAllMatching can make this better.

> 
> > Source/WebCore/rendering/RenderSearchField.cpp:96
> > +    m_recentSearches.insert(0, std::make_pair(value, (double)time(nullptr)));
> 
> We should definitely not be using the C standard library function time and
> converting it to a double! If we use std::chrono, then it would be
> std::chrono::system_clock::now().

I will change the time type to use std::chromo::system_clock::time_point instead of double! Thanks for the suggestions.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20150917/cde3961a/attachment.html>


More information about the webkit-unassigned mailing list