Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Server Development
Habbo Retros
Habbo Development
Starlight [C#/.NET Core/Dapper]
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="TheGeneral" data-source="post: 471662" data-attributes="member: 73182"><p>Great, then make it a struct.</p><p></p><p>Actually, no. The data has already been received (At least I really hope). As the message has a prefixed length + header thus I assume that IClientMessage contains all the bytestream bytes already.</p><p></p><p>Implementation is for [USER=72299]@Damien[/USER] to decide. The [ICODE]Invoke()[/ICODE] method is not slow. [ICODE]GetConstructor()[/ICODE] is (relatively!) slow though you could cache the result of that at startup. Then once you've got Invoke, its the same speed as a regular constructor call. If you're already worrying about performance at this time, and if the decision now is going to permanently affect your whole code base, then you're doing it wrong as it would indicate that it is not easy to refactor or replace / substiture parts of your code. Also I think he is already using the Activator anyways (or he has to re-use the packet instances which I certainly hope he isn't doing...)</p><p></p><p>If you're really worried about compile time, use code generators to generate the code for you.</p><p></p><p>Shouldn't really matter. You could just call the method with a bunch of data wrapped in an [ICODE]IClientMessage[/ICODE] and observe the result. You just don't have a specific object and its own logic behavior, which you just said it doesn't need, to possibly affect the result. [ICODE]1 + 1 [/ICODE] is pretty static to me and could be tested too. </p><p></p><p>Could do something along the lines of:</p><p></p><p>[CODE]/// Probably has some lookup table of header / packet type (IEventArgs) somewhere I assume.</p><p>var packetDefinitions = new Dictionary<ushort, Type>();</p><p>var factories = packetDefinitions.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.GetConstructor(new[] { typeof(IClientMessage) }));</p><p></p><p>var packetInstance = factories[4000].Invoke(message);</p><p>[/CODE]</p></blockquote><p></p>
[QUOTE="TheGeneral, post: 471662, member: 73182"] Great, then make it a struct. Actually, no. The data has already been received (At least I really hope). As the message has a prefixed length + header thus I assume that IClientMessage contains all the bytestream bytes already. Implementation is for [USER=72299]@Damien[/USER] to decide. The [ICODE]Invoke()[/ICODE] method is not slow. [ICODE]GetConstructor()[/ICODE] is (relatively!) slow though you could cache the result of that at startup. Then once you've got Invoke, its the same speed as a regular constructor call. If you're already worrying about performance at this time, and if the decision now is going to permanently affect your whole code base, then you're doing it wrong as it would indicate that it is not easy to refactor or replace / substiture parts of your code. Also I think he is already using the Activator anyways (or he has to re-use the packet instances which I certainly hope he isn't doing...) If you're really worried about compile time, use code generators to generate the code for you. Shouldn't really matter. You could just call the method with a bunch of data wrapped in an [ICODE]IClientMessage[/ICODE] and observe the result. You just don't have a specific object and its own logic behavior, which you just said it doesn't need, to possibly affect the result. [ICODE]1 + 1 [/ICODE] is pretty static to me and could be tested too. Could do something along the lines of: [CODE]/// Probably has some lookup table of header / packet type (IEventArgs) somewhere I assume. var packetDefinitions = new Dictionary<ushort, Type>(); var factories = packetDefinitions.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.GetConstructor(new[] { typeof(IClientMessage) })); var packetInstance = factories[4000].Invoke(message); [/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Development
Starlight [C#/.NET Core/Dapper]
Top