Skip to content

Conversation

@jsza
Copy link
Contributor

@jsza jsza commented Nov 3, 2017

Fixes #221.

I feel like I'm missing something with this fix, but it works with some light testing.

@jsza
Copy link
Contributor Author

jsza commented Nov 3, 2017

Would it perhaps be better to implement StringTable.__contains__ on the C++ side?

@jordanbriere
Copy link
Contributor

Hey, thank you! I can see where it was not optimized at all with the iteration. However, an even faster way would probably be to use engine_sound.is_sound_precached.

@jsza
Copy link
Contributor Author

jsza commented Nov 3, 2017

@invincibleqc Just tested on TF2 and CS:S, it looks like engine_sound.is_sound_precached always returns True for any string. I'll add a comment to the code warning about that.

@Ayuto
Copy link
Member

Ayuto commented Nov 3, 2017

Yep, contains would be the best solution. If the engine function always returns True, we should remove it.

@jordanbriere jordanbriere merged commit 805daf5 into Source-Python-Dev-Team:master Nov 3, 2017
@jordanbriere
Copy link
Contributor

jordanbriere commented Nov 3, 2017

Yes, after searching I found a thread that mentions the issue with is_sound_precached and is the reason why it was switched to use the string tables. Exposing a __contains__ method on the c++ side could be a tiny bit faster but I think the difference from your proposal would be negligible. I went ahead and merged your pull request, thank you!

If the engine function always returns True, we should remove it.

Definitely. But is that method only returning True on OrangeBox games or all engines?

@jordanbriere
Copy link
Contributor

After thinking about it, went ahead and added a __contains__ wrapper directly to the StringTable class because while this PR was fixing this particular case, the performance issue was directly in the string tables implementation.

As for is_sound_precached, I'm tempted to propose wrapping it on the engines affected over removing it drastically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sound.is_precached and StreamSound.is_precached performance

3 participants