octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #59706] Avoid "canonicalize_file_name" on Wind


From: Rik
Subject: [Octave-bug-tracker] [bug #59706] Avoid "canonicalize_file_name" on Windows
Date: Tue, 22 Dec 2020 11:06:39 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36

Follow-up Comment #25, bug #59706 (project octave):

One last thought on optimization.  On the development branch the regular
expression is now static and const so it is calculated only once.  Even
thought we can't make it 'const' on stable, we could declare it static which I
believe would mean it is only calculated and initialized once as well.

Here's a diff to show what I mean.


diff -r 45abff4199d8 liboctave/system/file-stat.cc
--- a/liboctave/system/file-stat.cc     Mon Dec 21 19:24:58 2020 +0100
+++ b/liboctave/system/file-stat.cc     Tue Dec 22 07:51:57 2020 -0800
@@ -206,7 +206,7 @@ namespace octave
           // trailing backslash.
           // FIXME: This pattern does not match all possible UNC roots:
           //       
https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-dtyp/62e862f4-2a51-452e-8eeb-dc4ff5ee33cc
-          regexp pat (R"(^\\\\[\w.-]+\\[\w\$-]+$)");
+          static regexp pat (R"(^\\\\[\w.-]+\\[\w\$-]+$)");
           if ((full_file_name.length () == 2 && full_file_name[1] == ':')
               || (full_file_name.length () > 4  && full_file_name[0] == '\\'
                   && full_file_name[1] == '\\' && pat.is_match
(full_file_name)))


The current solution is good in that it doesn't call is_match() unless it
absolutely has to.  But, it does call the regexp parser every time stat() is
called to construct an internal regexp object from the string specifying the
pattern, and that can't be quick either.

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?59706>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]