Opened 12 years ago

Closed 12 years ago

Last modified 8 months ago

#8694 closed patch (wontfix)

Minor tweak to rate.cpp

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

Description

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 12 years ago.
Small tweak to rate.cpp

Download all attachments as: .zip

Change History (4)

Changed 12 years ago by SF/robinwatts

Attachment: SoundRateTweak added

Small tweak to rate.cpp

comment:1 Changed 12 years ago by fingolfin

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 Changed 12 years ago by fingolfin

Owner: set to fingolfin
Resolution: wontfix
Status: newclosed

comment:3 Changed 8 months ago by digitall

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