Opened 17 years ago

Closed 17 years ago

Last modified 6 years ago

#8694 closed patch (wontfix)

Minor tweak to rate.cpp

Reported by: SF/robinwatts Owned by: fingolfin
Priority: normal Component: Audio
Version: Keywords:
Cc: Game:


Fingolfin points out that some compilers are crap at optimising array accesses due to pointer aliasing.

This patch therefore avoids using the 2 place arrays, and instead uses 2 normal variables.

This produces larger source, but any decent compiler should only keep one side of the if when it does the template instantiation, so will work out better overall.

Ticket imported from: #1738426. Ticket imported from: patches/799.

Attachments (1)

SoundRateTweak (3.2 KB ) - added by SF/robinwatts 17 years ago.
Small tweak to rate.cpp

Download all attachments as: .zip

Change History (4)

by SF/robinwatts, 17 years ago

Attachment: SoundRateTweak added

Small tweak to rate.cpp

comment:1 by fingolfin, 17 years ago

Thanks for this, but I just commited an alternate patch which also resolves this "issue", but in an (IMHO) slightly more elegant fashion: I really liked your out[reverseStereo ^ 1] trick, as it avoids duplicating code inside an if/else construct, and even a bad optimizer should be able to deal with this efficiently. So I was loathe to let go of this neat technique.

Hence, what I did was to use this indexing on obuf instead (were we can't avoid writing to a pointer anyway). Best of both worlds, so to speak :-)

comment:2 by fingolfin, 17 years ago

Owner: set to fingolfin
Resolution: wontfix
Status: newclosed

comment:3 by digitall, 6 years ago

Component: Audio
Note: See TracTickets for help on using tickets.