Skip to content

Commit

Permalink
erf handling: fix performance bottleneck when loading large erf files
Browse files Browse the repository at this point in the history
  • Loading branch information
niv committed May 1, 2012
1 parent c7484bd commit 9edcc95
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/nwn/erf.rb
Expand Up @@ -133,12 +133,12 @@ def write_to io
[c.resref, @content.index(c), c.res_type, 0].pack("a#{fnlen} V v v")
}.join("")

pre_offset = 160 + locstr.size + keylist.size + 8 * @content.size
offset = 160 + locstr.size + keylist.size + 8 * @content.size

reslist = @content.map {|c|
offset = pre_offset +
@content[0, @content.index(c)].inject(0) {|sum,x| sum + x.size }
[offset, c.size].pack("V V")
r = [offset, c.size].pack("V V")
offset += c.size
r
}.join("")

offset_to_locstr = 160
Expand Down

0 comments on commit 9edcc95

Please sign in to comment.