Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Removed line breaks?
Joking I'm curious to know the "before" and "after" if you can't share code, at least the logic. No bad intention but I always like to see what others do to improve code :) -
0xTJ3897y@gitpush Essentially, I have a 2D array which I use as a guide for which data means what from the inputs, and where to put it in the output. Between those two steps, the array determines in which field or property of a class each piece of data is stored. I want to make the 2D array easy to configure in source, perhaps later user-configurable during excecution.
I initially had it determining where to put stuff every loop excecution, because some of the pieces of data go into fields, others into properties, and I had to determine which one was which each time. I knew this was inneficient, but it worked. -
0xTJ3897y@gitpush @0xTJ I've since spent a couple hours struggling against VS to get it to be able to run a set those properties and fields according to what is determined only once, but had issues as the FieldInfo and PropertyInfo (which both inherit from MemberInfo) classes don't quite play nice enough. Eventually, I got it working by storing MethodInfo for each element in the top level of the 2D array, so I don't have to determine the subclass everytime, I just run the method on the subclass instance, because I know it's there. Probably not the safest way of doing things, but it should be safe enough for me.
What I've written probably doesn't make sense without seeing the code, but I should probably get off my phone, and keep working. -
@0xTJ From what I understood you were keeping references to methods in your array so that based on input you decide which function you need to produce output? Maybe I'm wrong, but I'd stay away from Arrays and go with something similar to this: https://stackoverflow.com/a/...
Maybe the original question is not related to your case, but if you can filter on an array you can filter on a class with cluster members using Lambda/LINQ as they have a better performance than arrays
Related Rants
*Cuts 7 slow lines of code down to 1 fast line of code*
*Looks around to see if coworkers can see me*
*Pumps both fists in the air*
undefined
pumped
efficient code
fast