<div dir="ltr">Thanks. Reverted in r335448.</div><br><div class="gmail_quote"><div dir="ltr">On Mon, Jun 25, 2018 at 9:59 AM Pavel Labath <<a href="mailto:labath@google.com">labath@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I believe the raison d'être of the needsNormalization function was the<br>
normalization process is not exactly cheap (it constructs a vector of<br>
StringRefs and whatnot), and measurements showed that this actually is<br>
important for performance of lldb<br>
<<a href="https://reviews.llvm.org/D45977#1078510" rel="noreferrer" target="_blank">https://reviews.llvm.org/D45977#1078510</a>>.<br>
On Sun, 24 Jun 2018 at 14:36, Jonas Devlieghere via lldb-commits<br>
<<a href="mailto:lldb-commits@lists.llvm.org" target="_blank">lldb-commits@lists.llvm.org</a>> wrote:<br>
><br>
> Author: jdevlieghere<br>
> Date: Sun Jun 24 06:31:44 2018<br>
> New Revision: 335432<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=335432&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=335432&view=rev</a><br>
> Log:<br>
> [FileSpec] Always normalize<br>
><br>
> Removing redundant components from the path seems pretty harmless.<br>
> Rather than checking whether this is necessary and then actually doing<br>
> so, always invoke remove_dots to start with a normalized path.<br>
><br>
> Modified:<br>
>     lldb/trunk/source/Utility/FileSpec.cpp<br>
><br>
> Modified: lldb/trunk/source/Utility/FileSpec.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/FileSpec.cpp?rev=335432&r1=335431&r2=335432&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/FileSpec.cpp?rev=335432&r1=335431&r2=335432&view=diff</a><br>
> ==============================================================================<br>
> --- lldb/trunk/source/Utility/FileSpec.cpp (original)<br>
> +++ lldb/trunk/source/Utility/FileSpec.cpp Sun Jun 24 06:31:44 2018<br>
> @@ -119,100 +119,6 @@ FileSpec::FileSpec(const FileSpec *rhs)<br>
>  //------------------------------------------------------------------<br>
>  FileSpec::~FileSpec() {}<br>
><br>
> -namespace {<br>
> -//------------------------------------------------------------------<br>
> -/// Safely get a character at the specified index.<br>
> -///<br>
> -/// @param[in] path<br>
> -///     A full, partial, or relative path to a file.<br>
> -///<br>
> -/// @param[in] i<br>
> -///     An index into path which may or may not be valid.<br>
> -///<br>
> -/// @return<br>
> -///   The character at index \a i if the index is valid, or 0 if<br>
> -///   the index is not valid.<br>
> -//------------------------------------------------------------------<br>
> -inline char safeCharAtIndex(const llvm::StringRef &path, size_t i) {<br>
> -  if (i < path.size())<br>
> -    return path[i];<br>
> -  return 0;<br>
> -}<br>
> -<br>
> -//------------------------------------------------------------------<br>
> -/// Check if a path needs to be normalized.<br>
> -///<br>
> -/// Check if a path needs to be normalized. We currently consider a<br>
> -/// path to need normalization if any of the following are true<br>
> -///  - path contains "/./"<br>
> -///  - path contains "/../"<br>
> -///  - path contains "//"<br>
> -///  - path ends with "/"<br>
> -/// Paths that start with "./" or with "../" are not considered to<br>
> -/// need normalization since we aren't trying to resolve the path,<br>
> -/// we are just trying to remove redundant things from the path.<br>
> -///<br>
> -/// @param[in] path<br>
> -///     A full, partial, or relative path to a file.<br>
> -///<br>
> -/// @return<br>
> -///   Returns \b true if the path needs to be normalized.<br>
> -//------------------------------------------------------------------<br>
> -bool needsNormalization(const llvm::StringRef &path) {<br>
> -  if (path.empty())<br>
> -    return false;<br>
> -  // We strip off leading "." values so these paths need to be normalized<br>
> -  if (path[0] == '.')<br>
> -    return true;<br>
> -  for (auto i = path.find_first_of("\\/"); i != llvm::StringRef::npos;<br>
> -       i = path.find_first_of("\\/", i + 1)) {<br>
> -    const auto next = safeCharAtIndex(path, i+1);<br>
> -    switch (next) {<br>
> -      case 0:<br>
> -        // path separator char at the end of the string which should be<br>
> -        // stripped unless it is the one and only character<br>
> -        return i > 0;<br>
> -      case '/':<br>
> -      case '\\':<br>
> -        // two path separator chars in the middle of a path needs to be<br>
> -        // normalized<br>
> -        if (i > 0)<br>
> -          return true;<br>
> -        ++i;<br>
> -        break;<br>
> -<br>
> -      case '.': {<br>
> -          const auto next_next = safeCharAtIndex(path, i+2);<br>
> -          switch (next_next) {<br>
> -            default: break;<br>
> -            case 0: return true; // ends with "/."<br>
> -            case '/':<br>
> -            case '\\':<br>
> -              return true; // contains "/./"<br>
> -            case '.': {<br>
> -              const auto next_next_next = safeCharAtIndex(path, i+3);<br>
> -              switch (next_next_next) {<br>
> -                default: break;<br>
> -                case 0: return true; // ends with "/.."<br>
> -                case '/':<br>
> -                case '\\':<br>
> -                  return true; // contains "/../"<br>
> -              }<br>
> -              break;<br>
> -            }<br>
> -          }<br>
> -        }<br>
> -        break;<br>
> -<br>
> -      default:<br>
> -        break;<br>
> -    }<br>
> -  }<br>
> -  return false;<br>
> -}<br>
> -<br>
> -<br>
> -}<br>
>  //------------------------------------------------------------------<br>
>  // Assignment operator.<br>
>  //------------------------------------------------------------------<br>
> @@ -252,8 +158,7 @@ void FileSpec::SetFile(llvm::StringRef p<br>
>    }<br>
><br>
>    // Normalize the path by removing ".", ".." and other redundant components.<br>
> -  if (needsNormalization(resolved))<br>
> -    llvm::sys::path::remove_dots(resolved, true, m_style);<br>
> +  llvm::sys::path::remove_dots(resolved, true, m_style);<br>
><br>
>    // Normalize back slashes to forward slashes<br>
>    if (m_style == Style::windows)<br>
> @@ -270,10 +175,10 @@ void FileSpec::SetFile(llvm::StringRef p<br>
>    // Split path into filename and directory. We rely on the underlying char<br>
>    // pointer to be nullptr when the components are empty.<br>
>    llvm::StringRef filename = llvm::sys::path::filename(resolved, m_style);<br>
> -  if(!filename.empty())<br>
> +  if (!filename.empty())<br>
>      m_filename.SetString(filename);<br>
>    llvm::StringRef directory = llvm::sys::path::parent_path(resolved, m_style);<br>
> -  if(!directory.empty())<br>
> +  if (!directory.empty())<br>
>      m_directory.SetString(directory);<br>
>  }<br>
><br>
> @@ -424,9 +329,8 @@ bool FileSpec::Equal(const FileSpec &a,<br>
>    // case sensitivity of equality test<br>
>    const bool case_sensitive = a.IsCaseSensitive() || b.IsCaseSensitive();<br>
><br>
> -  const bool filenames_equal = ConstString::Equals(a.m_filename,<br>
> -                                                   b.m_filename,<br>
> -                                                   case_sensitive);<br>
> +  const bool filenames_equal =<br>
> +      ConstString::Equals(a.m_filename, b.m_filename, case_sensitive);<br>
><br>
>    if (!filenames_equal)<br>
>      return false;<br>
> @@ -712,9 +616,7 @@ bool FileSpec::IsSourceImplementationFil<br>
>    return g_source_file_regex.Execute(extension.GetStringRef());<br>
>  }<br>
><br>
> -bool FileSpec::IsRelative() const {<br>
> -  return !IsAbsolute();<br>
> -}<br>
> +bool FileSpec::IsRelative() const { return !IsAbsolute(); }<br>
><br>
>  bool FileSpec::IsAbsolute() const {<br>
>    llvm::SmallString<64> current_path;<br>
><br>
><br>
> _______________________________________________<br>
> lldb-commits mailing list<br>
> <a href="mailto:lldb-commits@lists.llvm.org" target="_blank">lldb-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits</a><br>
</blockquote></div>