[kgm/ncm/kwm] refactor: improve performance for large file

This commit is contained in:
鲁树人
2024-09-15 23:25:19 +01:00
parent fd73e8b9a3
commit da806d7ad4
4 changed files with 18 additions and 30 deletions

View File

@@ -182,9 +182,8 @@ impl NCMFile {
where
T: AsMut<[u8]> + ?Sized,
{
let key_stream = self.audio_rc4_key_stream.iter().cycle().skip(offset & 0xff);
for (datum, &key) in data.as_mut().iter_mut().zip(key_stream) {
*datum ^= key;
for (datum, offset) in data.as_mut().iter_mut().zip(offset..) {
*datum ^= self.audio_rc4_key_stream[offset % self.audio_rc4_key_stream.len()];
}
}
}