![]() |
Tiny optimization - Printable Version +- Mirage Source (https://mirage-engine.uk/forums) +-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61) +--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18) +---- Forum: Source Code Development (https://mirage-engine.uk/forums/forumdisplay.php?fid=51) +----- Forum: Mirage Source 4 (Visual Basic 6) (https://mirage-engine.uk/forums/forumdisplay.php?fid=44) +----- Thread: Tiny optimization (/showthread.php?tid=2101) |
Tiny optimization - Jacob - 16-09-2008 I didn't get a chance to work on MS4 much because my baby has been sick. I saw one tiny thing in modGameLogic. When you hit enter it checks every command even if you don't have the "/", so why not check for that first? Sub HandleKeyPresses Add: Code: If Left$(MyText, 1) = "/" Then Code: ' // Commands // Add: Code: End If Code: ' Ban destroy Re: Tiny optimization - skillzalot - 16-09-2008 Thanks for the small fix I added it already Re: Tiny optimization - DarkC - 16-09-2008 Nice, I just added this. Re: Tiny optimization - Joost - 16-09-2008 To add on to this, Instead of using Mid(1, somthing Use Left(something) Using Mid here is obviously quite stupid, and I (without any sources to back it up) assume Left is way faster than Mid. Re: Tiny optimization - Vahz - 16-09-2008 i think Dugor forgot about these... Code: If Mid$(MyText, 1, 1) = vbQuote Then Code: If Mid$(MyText, 1, 1) = "=" Then you should place them right before Code: If Left$(MyText, 1) = "/" Then and add an access check Code: If GetPlayerAccess(MyIndex) >0 Then Re: Tiny optimization - Jacob - 16-09-2008 From: http://www.aivosto.com/vbtips/stringopt2.html ![]() So using Left$ is faster than Mid$. Re: Tiny optimization - Jacob - 16-09-2008 Vahz Wrote:i think Dugor forgot about these... You are correct, I did forget about those. You would have to move those out of the 'Checking for commands' section and have another If Then statement to check for those. Re: Tiny optimization - Rory - 16-09-2008 Vahz Wrote:i think Dugor forgot about these... What about Normal Player commands. Re: Tiny optimization - Jacob - 16-09-2008 Okay I was thinking of a little bit different way to do the commands. What i came up with is very similar to HandleData. This method would make it easier for users to add commands without using left, mid and whatnot and counting letters. HandleKeyPresses Add Code: Dim Command() As String After Code: If Left$(MyText, 1) = "/" Then Add Code: Command = Split(MyText, " ") Add: Code: Select Case Command(0) The following is just a simple example: Code: Case "/help" The following will first check to make sure there's more than one string in our array so we don't error out, then it will send the second string in the array. The first string will always be the command. Code: Case "/info" Code: ' Party request Code: ' Giving another player access Just a little something to tell someone they don't have a valid command. Code: Case Else Then right before the Code: End If Code: If Left$(MyText, 1) = "/" Then Add Code: End Select Just an idea. Let's hear what everyone thinks. Re: Tiny optimization - Jacob - 16-09-2008 Like Verrigans source ? I may write up something for that ... who knows. Re: Tiny optimization - Jacob - 16-09-2008 [quote="DFA"]use LenB over Len coz LenB is just plain leet compared to Len xD, na jk, they both serve 2 different purposes if dugor does the next version, dont forget to finish the packet enumeration > Re: Tiny optimization - Jacob - 16-09-2008 I was just taking my info from: http://www.aivosto.com/vbtips/stringopt2.html Quote:Len and LenB. The fastest functions are Len and LenB. These are lightning fast functions that simply read the 2 length bytes at the start of the string area. Len is implemented in 6 assembly instructions in the VB runtime. LenB is even shorter: it runs just 5 instructions. In principle, LenB should run faster. In practice, this is not the case. Their performance is equal on today's processors. Re: Tiny optimization - Matt - 18-09-2008 Lea Wrote:It said inside the stuff Dugor quoted Fixed. Re: Tiny optimization - Robin - 18-09-2008 Perfekt Wrote:Lea Wrote:Matt is black Fixed. Re: Tiny optimization - Matt - 18-09-2008 Robin Wrote:Perfekt Wrote:Lea Wrote:Matt is black ... |