Log of #mupdf at irc.freenode.net.

Search:
 <<<Back 1 day (to 2020/03/30)Fwd 1 day (to 2020/04/01)>>>20200331 
avih ator: i wrote a hash table and used it for interning. works well. i then want to use it (the same table) for all strings, initially with a type mem/interned/literal so that they can be GC'ed/killed at the right times or not at all, and then use a table for properties as well (not their names, make properties a hash table where name is their key)11:53.25 
  i noticed that at the end of the v8 bench suite there are 24000 interned strings. at the end of splay.js alone there are 8300 interned strings, 8000 of them are array indexes.11:54.49 
  if there would be a code path which won't convert number-to-string and back for array index properties, i think it would be great.11:55.43 
  my hash table is fully generic (configurable strategy, key type, hash function used, etc). after i understand the needs of all the domains where it's needed then i can reduce its generality and only make configurable things which are different between different table use cases11:58.04 
  fwiw, with a strategy of doubling the slots (rehash) when the population reaches 2x slots (i.e. 2 items per slot on average just before rehash), ~60-70% of nodes are found as the first node of a slot, ~25-30% on the second node of a slot, which covers 90-95% of the nodes12:00.54 
  the typically there are very few slots (1-2%) with chains of 4 or more nodes12:01.52 
  key-type is configurable for now because i envision array index properties with unsigned int key, i.e. not a string.12:19.30 
  (the configuration is runtime, not compile time, i.e. a table is two pointers: 1 to the actual table and its data which starts as null, and one to a config struct which contains functions to ket the key, hash it, etc)12:21.01 
  s/ket/get/12:21.28 
  also, walks are a macro which supports unlink of nodes and/or break. though interning only uses walks without break, where either all the nodes are unlinked and released (freestate) or just printed (dumpstrings)12:23.22 
  the walks are nice. no need for callback with context. very natural to use. pretty much the same as you would in a for-loop, just as a macro.12:24.44 
  for instance, you could do: void kill_some(js_State *J) { js_StringNode *node; JSH_WALK(J, &J->strings, node, {if (strst(node->string, "foo")) { JSH_UNLINK_NODE; js_free(J, node); break}); }12:29.02 
  (where J->string is the hash table root)12:32.05 
  (the walk IS just a loop, well, two nested loops - over the slots and over the chain of each slot, where "break" at the inner loop - where the code block is invoked, also breaks from the outer loop with a simple "trick"12:36.20 
  (for (..; !broke && ...;...) for (...) { broke = 1; <user code block>; block = 0; }12:39.38 
  broke = 0 *12:40.02 
  and the code block is not limited to guarding commas only inside parenthesis, so any arbitrary block works. it uses __VA_ARGS__ to interpret the "rest" of the macro arguments as one big arbitrary thing12:42.27 
  (pretty straight forward, and yet highly effective)12:43.01 
Robin_Watts_ __VA_ARGS__ is a gcc extension, right?13:55.19 
  So we can't take that on in our source.13:55.48 
avih afaik it's c9914:01.30 
  6.10.2.5: "The identifier _ _VA_ARGS_ _ shall occur only in the replacement-list of a function-like macro that uses the ellipsis notation in the parameters."14:02.09 
  (i.e. yes, it's c99, not gnu extension (anymore?))14:03.17 
Robin_Watts_ avih: But it gives VS2017 conniptions, I think.14:03.26 
avih dunno14:03.40 
Robin_Watts_ AIUI, C99 supports __VA_ARGS__ to be "backwardly compatible", but it has a nicer way of working itself.14:04.30 
  Using that "nicer way" would be better, I think, cos there is more hope of earlier VS supporting it.14:04.59 
  I'm going by a couple of quick google searches here, so I could easily be wrong.14:05.27 
avih according to https://stackoverflow.com/a/7459869/3339341 it should work well with vs2010 or later14:05.30 
  is there a "nicer way" in c99? what is it?14:06.42 
Robin_Watts_ avih: https://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html14:07.56 
  The last line on that page, which is causing me trouble to grok is what lead me to believe there may be a "more official" way.14:08.21 
  but I may be misreading it.14:08.28 
avih i'm looking at the c99 standard, and i don't see anything related beyond VA_AGS. (related being one argument which is not limited to parenthesis guards, and also considers square or curly braces as comma guards)14:09.39 
  Robin_Watts_: i think the backward compatibility is for arg... (i.e. i think possibly empty list14:12.02 
Robin_Watts_ avih: OK, ignore me then :)14:12.04 
avih oh, "named argument", e.g. #define foo(x, bar...) then bar is what __VA_ARGS__ is at #define foo(x, ...)14:13.33 
  and that's what it's maintaining for backward compatibility, but it's not required anymore with va args14:14.18 
 <<<Back 1 day (to 2020/03/30)Forward 1 day (to 2020/04/01)>>> 
ghostscript.com #ghostscript
Search: