[Thunar-workers] [DokuWiki] page changed: implementation:mime-glob-match

thunar-workers at xfce.org thunar-workers at xfce.org
Mon Mar 7 01:30:09 CET 2005


A page in your DokuWiki was added or changed. Here are the details:

Date        : 2005/03/07 00:30
Browser     : Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.5) Gecko/20050122 Firefox/1.0
IP-Address  : 217.229.249.18
Hostname    : pD9E5F912.dip.t-dialin.net
Old Revision: http://thunar.xfce.org/wiki/implementation:mime-glob-match?rev=1110151156
New Revision: http://thunar.xfce.org/wiki/implementation:mime-glob-match
Edit Summary: 
User        : benny

@@ -50,8 +50,32 @@
  that vendors will add that many additional literal patterns, we should
  go with a simple string comparison here. The important fact is that we
  need to sort the list of literal patterns by their length to make sure
  we check the longest patterns first.
+ 
+ Assuming the patterns are sorted by string length, then the following
+ implementation should provide reasonable performance (pseudo-code):
+ 
+ <code c>
+ for (pattern in literal patterns)
+   {
+     for (f = filename, p = pattern; *f != '\0'; ++f, ++p)
+       {
+         if (*p == '\0')
+           goto no_match;
+         else if (*p != *f)
+           break;
+       }
+   }
+ </code>
+ 
+ The //literal patterns// should be stored in an array. At best,
+ everything related to the //literal patterns// would be stored
+ in one memory chunk: The array of ''(pattern pointer, type
+ pointer)'' tuples first, then the pattern strings (pointed to
+ by the ''pattern pointer''s). That way, a certain amount of
+ locality is granted, heap fragmentation is reduced and prefetching
+ can be used on modern CPUs if necessary.
  
  
  
  === Simple Patterns ===



-- 
This mail was generated by DokuWiki at
http://thunar.xfce.org/wiki/



More information about the Thunar-workers mailing list