Skip to content

Optimize code by replacing ^ operators #76

@T-Rizzle12

Description

@T-Rizzle12

While working on #75, I was looking at the pull requests submitted to the Garrysmod's GitHub repository and noticed Facepunch/garrysmod#2198. Apparently ^ is slower than * since ^ is a C call. One of the things I was focusing on while optimizing in the code was the amount of Lua to C calls. If you look at the code, you might have noticed the bot:GetTable() calls. This allows me to get the bot's Lua table which makes only ONE C call for ALL VARIABLES rather than using bot.variableName = true, which is two to three C calls FOR EACH VARIABLE. That is a lot of overhead and really slows down the game when running multiple bots. Since ^ is a C call to math.pow, its much faster for me to index the botTable twice and multiply it rather than run ^.

TLDR; ^ is a C call that makes the code slower and variableName * variableName is much faster which is important for this addon.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

Status
No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions