<html>
<head>
<base href="https://bugs.webkit.org/" />
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - We should also store the time information for recent searches"
href="https://bugs.webkit.org/show_bug.cgi?id=148388#c17">Comment # 17</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - We should also store the time information for recent searches"
href="https://bugs.webkit.org/show_bug.cgi?id=148388">bug 148388</a>
from <span class="vcard"><a class="email" href="mailto:darin@apple.com" title="Darin Adler <darin@apple.com>"> <span class="fn">Darin Adler</span></a>
</span></b>
<pre>Comment on <span class=""><a href="attachment.cgi?id=261270&action=diff" name="attach_261270" title="Patch v3">attachment 261270</a> <a href="attachment.cgi?id=261270&action=edit" title="Patch v3">[details]</a></span>
Patch v3
View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=261270&action=review">https://bugs.webkit.org/attachment.cgi?id=261270&action=review</a>
<span class="quote">> 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;</span >
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.
Also, I suggest for new code we use std::chrono. Instead of double we would use std::chrono::time_point<std::chrono::system_clock>.
<span class="quote">> 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);
> + }</span >
This is really ugly, especially the static_cast<int> part. We should try to do a little better.
<span class="quote">> Source/WebCore/rendering/RenderSearchField.cpp:96
> + m_recentSearches.insert(0, std::make_pair(value, (double)time(nullptr)));</span >
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().</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>