So I have had this dilemma for quite a while now back since the early days of Autonauts. Let me give you an example of some code that I have come up with first.
It's too long for 1 picture alone.
When the code runs, picking something up from the ground is much slower than picking up an object from a storage container. The reason for this has to do with the way the bots try to find items. If I try to take out the "Find Nearest..." command, the bot will not pick up the item. This adds a slight delay to the actions. The mechanics that I have observed for Autonauts is that for every line of code you add, this adds a 1-tick delay. For every "Repeat Until..." function you add, there is a negligible delay; probably around 1-2 milliseconds. Just minimizing the amount of code will not save you time however. I found that filling the bots inventory/hands between deliveries/stows save a significant amount of time. In order to maximize efficiency, some features may be needed.
1. Bots should remember the "Find Nearest..." command that was last played. This should get rid of a few lines of code. I am not sure if "global" commands will be implemented in the future or not, in which case that feature might override this one.
2. Cycling should stack similar items. This would reduce the amount of times you would have to cycle the same item to empty your inventory.
If anyone has found a different technique that is just as fast and uses less code or is faster in general, then I am all ears.