Jump to content

Very specific Papyrus Performance Question


Recommended Posts

Hi, I am an amateur modder with an interest in scripting but with no formal education in programming or software engineering, I work in an Hospital no IT formation at all but the "How to use a pc for medical use" exam at university xD

 

I made a mod for AAF, from which it receives an event and do some calculations on an array of actors.

Before doing so I copy the received array into an array of my own sorting the elements into some specific index that I need for my calculations depending on the returned index of the playerref.

Event AAF:AAF_API.OnSceneInit(AAF:AAF_API akSender, Var[] akArgs)
        Actor[] akArgs2 = Utility.VarToVarArray(akArgs[1]) as Actor[]
        Actor second1
        Actor third1	
        If akArgs2[0] as Actor == PlayerREf
		Second1 = akArgs2[1] as Actor
		Third1	= akArgs2[2] as Actor
	ElseIf akArgs2[1] as Actor == PlayerREF
		Second1 = akArgs2[0] as Actor
		Third1 = akArgs2[2] as Actor
	Else
		Second1 = akArgs2[0] as Actor
		Third1 = akArgs2[1] as Actor
	EndIf
       ; [...] etc etc various functions called on playerref, second1 and third1
EndEvent

Knowing that this event return at least an actor array of 1 element (the playerref) so some calculations are always done with it, and that if the returned array.length is less than three second1 and/or third1 can be none this can fire an error in the papyrus log about the akargs[2] array being out of range, my question is:

 

What is more performance friendly?

- Let the virtual machine automatically aborting the lines with functions called on none actors, consider that I disable papyrus logging in Fallout4.ini? (When the VM abort those function calls because of second1 or third1 are none, the script goes on with its execution without other consequences)

- Or make a serie of If statements to check for the returned array length before doing my calculations?

 

Obviosly the checks before using the returned array would be a better coding practice to at least don't pollute the logs but mine is a pure performance question and I am not 100% sure of doing a correct profiling.

 

I know that probably we are talking about microseconds xD but curiosity burns.

 

Thank you!

Edited by anghelos92
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...