util/{Static,Foreign}FifoBuffer: lazy shift
Reduce the number of unnecessary memmove() calls.
This commit is contained in:
		| @@ -147,7 +147,11 @@ public: | ||||
| 	 * When you are finished, call append(). | ||||
| 	 */ | ||||
| 	Range Write() { | ||||
| 		Shift(); | ||||
| 		if (IsEmpty()) | ||||
| 			Clear(); | ||||
| 		else if (tail == capacity) | ||||
| 			Shift(); | ||||
|  | ||||
| 		return Range(data + tail, capacity - tail); | ||||
| 	} | ||||
|  | ||||
|   | ||||
| @@ -92,7 +92,11 @@ public: | ||||
| 	 * When you are finished, call append(). | ||||
| 	 */ | ||||
| 	Range Write() { | ||||
| 		Shift(); | ||||
| 		if (IsEmpty()) | ||||
| 			Clear(); | ||||
| 		else if (tail == size) | ||||
| 			Shift(); | ||||
|  | ||||
| 		return Range(data + tail, size - tail); | ||||
| 	} | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Max Kellermann
					Max Kellermann