Optimisation help needed

Subtle problem:
  current.children[char] = eoword ? DawgNode::EOW : nodes[ptr]

doesn't work because a node could be both EOW *and* have children. But
looks like a very nice clean approach on the whole - will happily
replace my old code with this.

martin

···

Robert Klemme <bob.news@gmx.net> wrote:

There we some errors still. I did a bit of fixing and tidying up. Most
interesting I find the simplification achieved by "EOW =
DawgNode.new.freeze".

(And yes, it turned out to be a very small fix - merely adding the eow
attribute back to every node and saying

      if char != 0
        current.children[char] = nodes[ptr]
        current.eow = eoword
      end

plus a few supporting changes elsewhere.)

martin

···

Martin DeMello <martindemello@yahoo.com> wrote:

Robert Klemme <bob.news@gmx.net> wrote:
>
> There we some errors still. I did a bit of fixing and tidying up. Most
> interesting I find the simplification achieved by "EOW =
> DawgNode.new.freeze".

Subtle problem:
  current.children[char] = eoword ? DawgNode::EOW : nodes[ptr]

doesn't work because a node could be both EOW *and* have children. But
looks like a very nice clean approach on the whole - will happily
replace my old code with this.

My turn to be too sleepy for this :slight_smile: Of course it's a bit more tricky
than that.

  current.children[char].eow = eoword if ptr > 1

seems to work; I'll bang on it some more in the morning.

martin

···

Martin DeMello <martindemello@yahoo.com> wrote:

(And yes, it turned out to be a very small fix - merely adding the eow
attribute back to every node and saying

      if char != 0
        current.children[char] = nodes[ptr]
        current.eow = eoword
      end