<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#c23">Comment # 23</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:zacharyli323&#64;gmail.com" title="Zach Li &lt;zacharyli323&#64;gmail.com&gt;"> <span class="fn">Zach Li</span></a>
</span></b>
        <pre>(In reply to <a href="show_bug.cgi?id=148388#c17">comment #17</a>)
<span class="quote">&gt; Comment on <span class="bz_obsolete"><a href="attachment.cgi?id=261270&amp;action=diff" name="attach_261270" title="Patch v3">attachment 261270</a> <a href="attachment.cgi?id=261270&amp;action=edit" title="Patch v3">[details]</a></span>
&gt; Patch v3
&gt; 
&gt; View in context:
&gt; <a href="https://bugs.webkit.org/attachment.cgi?id=261270&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=261270&amp;action=review</a>
&gt; 
&gt; &gt; Source/WebCore/platform/SearchPopupMenu.h:36
&gt; &gt; +    virtual void saveRecentSearches(const AtomicString&amp; name, const Vector&lt;std::pair&lt;String, double&gt;&gt;&amp; searchItems) = 0;
&gt; &gt; +    virtual void loadRecentSearches(const AtomicString&amp; name, Vector&lt;std::pair&lt;String, double&gt;&gt;&amp; searchItems) = 0;
&gt; 
&gt; This interface is confusing. Nothing about std::pair&lt;String, double&gt;
&gt; indicates to me that one element is the search string and the other is a
&gt; time. We’d probably be better off with a struct so we can name the two
&gt; members.</span >

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

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

Totally agreed. I think removeAllMatching can make this better.

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

I will change the time type to use std::chromo::system_clock::time_point instead of double! Thanks for the suggestions.</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>