How to make function more efficient

Hello everyone,

I am using a function to control a stepper motor driven actuator different distances and directions. the function is taking two inputs one for direction where HIGH means down and LOW means up, and another variable for the distance moved in mm. I was wondering how I could put something in the function so instead of typing HIGH or low for an input I could type up or down. I was also wondering if there is a way I could have a third variable to decide which motor to use. each motor however uses different pins and moves in a different direction given HIGH/LOW, so those would need to change depending on the third variable.

// defines pins numbers
const int stepPina = 6; 
const int dirPina = 5; 
const int enPina = 7;

void setup() {

   // Sets the two pins as Outputs
  pinMode(stepPina,OUTPUT); 
  pinMode(dirPina,OUTPUT);

  pinMode(enPina,OUTPUT);
  digitalWrite(enPina,LOW); 

}

void loop() {

  movemotor(10, LOW);
  delay(500);
  
}

//motor simplification function
void movemotor(int dist, int dir) {
  dist = dist*100;

   digitalWrite(dirPina, dir); // Enable particular direction
   for(int x = 0; x < dist; x++) {
     digitalWrite(stepPina,HIGH); 
     delayMicroseconds(500); 
     digitalWrite(stepPina,LOW); 
     delayMicroseconds(500);
  }  
}

thank you for any help

text substitution macro:
#define up 0
or
#define up LOW

This won't have any effect on "efficiency". The compiled code will be the same.

you could use an array of struct where you store the Servo information (pins) and you could pass the index in that array to your movemotor() function or you could use the Stepper library...

You can put the step, direction, and enable pins in arrays:

const size_t NumberOfSteppers = 2;

const byte DirectionPins[NumberOfSteppers] = {5, 2};
const byte StepPins[NumberOfSteppers] = {6, 3};
const byte EnablePins[NumberOfSteppers] = {7, 4};

const int UP_DIRECTION = HIGH;
const int DOWN_DIRECTION = LOW;

void setup()
{
  for (size_t i = 0; i < NumberOfSteppers; i++)
  {
    pinMode(DirectionPins[i], OUTPUT);
    pinMode(StepPins[i], OUTPUT);
    digitalWrite(EnablePins[i], LOW);
    pinMode(EnablePins[i], OUTPUT);
  }
}

void loop()
{

  for (size_t i = 0; i < NumberOfSteppers; i++)
  {
    movemotor(i, 10, UP_DIRECTION);
  }
  delay(500);
}

//motor simplification function
void movemotor(size_t stepper, int dist, int direction)
{
  digitalWrite(DirectionPins[stepper], direction); // Enable particular direction
  for (int x = 0; x < dist * 100; x++)
  {
    digitalWrite(StepPins[stepper], HIGH);
    delayMicroseconds(500);
    digitalWrite(StepPins[stepper], LOW);
    delayMicroseconds(500);
  }
}