فهرست منبع

small calculation reduction

tarfeef101 6 سال پیش
والد
کامیت
0629d293c0
1فایلهای تغییر یافته به همراه1 افزوده شده و 13 حذف شده
  1. 1 13
      kern/synchprobs/traffic_synch.c

+ 1 - 13
kern/synchprobs/traffic_synch.c

@@ -43,18 +43,6 @@ static car * newcar(Direction origin, Direction dest)
   return temp;
 }
 
-// push a car to the active array
-static void push(car * newcar)
-{
-  // dirs + origin is our offset for where to start in the array
-  // compass + origin is the array we use to determine what to add to the first number
-  // newcar->dest gives the direction, which we use to find the offset indicating it's additive value
-  int total = dirs[newcar->origin] + *(compass[newcar->origin] + newcar->dest);
-
-  // with our offset, set the pointer here to newcar
-  active[total] = newcar;
-}
-
 // called when a car clears the intersection
 static void clearint(car * done, int pos)
 {
@@ -148,7 +136,7 @@ void intersection_before_entry(Direction origin, Direction destination)
     }
   }
   
-  push(new);
+  active[(dirs[new->origin] + *(compass[new->origin] + new->dest))] = new;
   lock_release(globlock);
 }