summaryrefslogtreecommitdiff
path: root/doc/recentchanges/change_171c429f829aac53cb449e3bb574d2a1669e025e._change
blob: 0ff2e820712c462364b18c22ac5584651834aac5 (plain)
  1. [[!meta author="""http://kerravonsen.dreamwidth.org/"""]]
  2. [[!meta authorurl="""http://kerravonsen.dreamwidth.org/"""]]
  3. [[!meta title="""change to todo/Improving_the_efficiency_of_match__95__glob on ikiwiki"""]]
  4. [[!meta permalink="http://ikiwiki.info/recentchanges/#change-171c429f829aac53cb449e3bb574d2a1669e025e"]]
  5. <div id="change-171c429f829aac53cb449e3bb574d2a1669e025e" class="metadata">
  6. <span class="desc"><br />Changed pages:</span>
  7. <span class="pagelinks">
  8. <a href="http://git.ikiwiki.info/?p=ikiwiki;a=blobdiff;f=doc/todo/Improving_the_efficiency_of_match__95__glob.mdwn;h=8f70f1dde4bbe7fd7b66807c36e6f4d7fd0b08b0;hp=0000000000000000000000000000000000000000;hb=171c429f829aac53cb449e3bb574d2a1669e025e;hpb=9c8f86ee9c59035c9462d2c69c7b89d0c9dbc3c2" title="diff" rel="nofollow">[[diff|wikiicons/diff.png]]</a><a href="http://ikiwiki.info/ikiwiki.cgi?page=todo%2FImproving_the_efficiency_of_match__95__glob&amp;do=goto" rel="nofollow">todo/Improving the efficiency of match&#95;glob</a>
  9. </span>
  10. <span class="desc"><br />Changed by:</span>
  11. <span class="committer">
  12. <a href="http://kerravonsen.dreamwidth.org/" rel="nofollow">kerravonsen [dreamwidth.org]</a>
  13. </span>
  14. <span class="desc"><br />Commit type:</span>
  15. <span class="committype">web</span>
  16. <span class="desc"><br />Date:</span>
  17. <span class="changedate"><span class="relativedate" title="Tue, 09 Nov 2010 20:53:10 -0400">20:53:10 11/09/10</span></span>
  18. <span class="desc"><br /></span>
  19. </div>
  20. <span class="revert">
  21. <a href="http://ikiwiki.info/ikiwiki.cgi?rev=171c429f829aac53cb449e3bb574d2a1669e025e&amp;do=revert" title="revert" rel="nofollow">[[revert|wikiicons/revert.png]]</a>
  22. </span>
  23. <div class="changelog">
  24. make match_glob faster - patch!<br />
  25. </div>
  26. <div class="diff">
  27. <pre>
  28. diff --git a/doc/todo/Improving_the_efficiency_of_match__95__glob.mdwn b/doc/todo/Improving_the_efficiency_of_match__95__glob.mdwn
  29. new file mode 100644
  30. index 0000000..8f70f1d
  31. --- /dev/null
  32. +++ b/doc/todo/Improving_the_efficiency_of_match__95__glob.mdwn
  33. @@ -0,0 +1,39 @@
  34. +I&#39;ve been profiling my IkiWiki to try to improve speed (with many pages makes speed even more important) and I&#39;ve written a patch to improve the speed of match_glob. This matcher is a good one to improve the speed of, because it gets called so many times.
  35. +
  36. +Here&#39;s my patch - please consider it! -- &#91;&#91;KathrynAndersen&#93;&#93;
  37. +
  38. +--------------------------------------------------------------
  39. +&lt;pre&gt;
  40. +diff --git a/IkiWiki.pm b/IkiWiki.pm
  41. +index 08a3d78..c187b98 100644
  42. +--- a/IkiWiki.pm
  43. ++++ b/IkiWiki.pm
  44. +@@ -2482,6 +2482,8 @@ sub derel ($$) {
  45. + return $path;
  46. + }
  47. +
  48. ++my %glob_cache;
  49. ++
  50. + sub match_glob ($$;@) {
  51. + my $page=shift;
  52. + my $glob=shift;
  53. +@@ -2489,8 +2491,15 @@ sub match_glob ($$;@) {
  54. +
  55. + $glob=derel($glob, $params{location});
  56. +
  57. +- my $regexp=IkiWiki::glob2re($glob);
  58. +- if ($page=~/^$regexp$/i) {
  59. ++ # Instead of converting the glob to a regex every time,
  60. ++ # cache the compiled regex to save time.
  61. ++ if (!exists $glob_cache{$glob}
  62. ++ or !defined $glob_cache{$glob})
  63. ++ {
  64. ++ my $re=IkiWiki::glob2re($glob);
  65. ++ $glob_cache{$glob} = qr/^$re$/i;
  66. ++ }
  67. ++ if ($page =~ $glob_cache{$glob}) {
  68. + if (! IkiWiki::isinternal($page) || $params{internal}) {
  69. + return IkiWiki::SuccessReason-&gt;new(&quot;$glob matches $page&quot;);
  70. + }
  71. +&lt;/pre&gt;
  72. +--------------------------------------------------------------
  73. </pre>
  74. </div>
  75. <!-- 171c429f829aac53cb449e3bb574d2a1669e025e -->