Digital HIGH, LOW Question

I'm using a zero cross detector to determine when a signal is positive and negative. That part of the circuit works fine but in another section I need to control a relay based on the signal without using delay(). I want to set the relay LOW when the zero cross is HIGH and the relay HIGH when the zero cross is LOW. I need to keep the code efficient so is there a way I can set the relay state opposite to the zero cross state without using if statements.

int crosspin=2;
int crosstime;
int prestate=0;
int state;
int pretime=0;
int peakpin=A8;
int relay=8;
int peak;
int ctr=0;


void setup() {
  // put your setup code here, to run once:
  
  pinMode(crosspin,INPUT);
  pinMode(peakpin,INPUT);
  pinMode(relay,OUTPUT);
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly: 
  
  state=digitalRead(crosspin);
  peak=analogRead(peakpin);
  Serial.print("peak= ");
  Serial.println(peak);
  
  digitalWrite(relay,-state);
  
  
  
  if(state==HIGH&&prestate==LOW){
    crosstime=millis()-pretime;
    Serial.print("time= ");
    Serial.println(crosstime);
    pretime=millis();
  }
  
  if(state==LOW&&prestate==HIGH){
    crosstime=millis()-pretime;
    Serial.print("time= ");
    Serial.println(crosstime);
    pretime=millis();
  }
  prestate=state;

}

Thanks for any help.

It would be best to use a boolean for state (or another variable if state can be other than 0 or 1..

bool state;

// do stuff to set state
    digitalWrite(relay,!state);

You use - for numbers, to invert a boolean you use ! (logical not)

  digitalWrite (relay, !digitalRead (crosspin)) ;

no need for any variables if you aren't holding on to state.