04.07.2017, 08:04
Quote:
So I change all my code to tquery, is there anything else I need to do to optimize it? How do I find the part in my code that is crashing the include?
|
strmid goes through a set of functions in order to achieve the same things as making an array equal to a string.
To squeeze the max. performance you can replace the `format` functions with `strcat` and create the arrays only when they're needed and not just create all the arrays at the start of the code, because if a player types the command in wrong way, the process is ran and stops at sscanf, and so you don't need most of those arrays you created before it.
`format` was proven to be slower than `strcat` by benchmarks. (this is not relevant to mysql_format, you still have to use it if you are dealing with unreliable strings and need to escape UNLESS you escape the unsafe string before it with mysql_escape_string, then you can use strcat, I noticed that you used in a query format the sign %s for a user nickname, which is a security vulnerability and so you should use %e for unsafe strings (strings that come from unreliable source), otherwise you're vulnerable to what so called "SQL Injections")
I assume the speed of that `format` function is slower than `strcat` because `format` is looping through the entire string in search of `%` signs and replacing them with arrays, while strcat only appends a string to its destination array.
The creation of arrays is really a minority, but again, if you want to save these microseconds you can also do this.
another thing you can do is replace sizeof() functions with actual numbers, because sizeof() is a function afterall.
pawn Код:
strmid(join, string, 0, strlen(string), 255);
Instead, you could even just omit the use of `string` and use directly `join` and `expire` arrays.
Quote:
Quote:
|
When you use them, they launch a query and the code continues to do whatever it does - without the information from the query.
Meanwhile the thread is standing on a line to be processed, afterwards when MySQL has finished processing the queries which he received before, he processes the query which you sent, when he finishes doing all that, MySQL sends the information back and a callback is being called.
The callback at the end holds all the information which he received from MySQL plus the extra data you typed into the mysql_tquery at the end