From d2df3eb24ea68eec5538fac73829b168f747e7a6 Mon Sep 17 00:00:00 2001 From: richiesams Date: Sat, 24 Aug 2013 00:16:59 -0500 Subject: ZVISION: Check if we can use getNextFrame() or getPreviousFrame() before using getFrameData() --- engines/zvision/rlf_animation.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'engines') diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp index 52ca96f0e1..5c0a88a18f 100644 --- a/engines/zvision/rlf_animation.cpp +++ b/engines/zvision/rlf_animation.cpp @@ -157,8 +157,14 @@ const uint16 *RlfAnimation::getFrameData(uint frameNumber) { assert(!_stream); assert(frameNumber < _frameCount && frameNumber >= 0); + // Since this method is so expensive, first check to see if we can use + // getNextFrame() or getPreviousFrame() since they are cheap. if (frameNumber == _currentFrame) { return _currentFrameBuffer; + } else if (_currentFrame + 1 == frameNumber) { + return getNextFrame(); + } else if (_currentFrame - 1 == frameNumber) { + return getPreviousFrame(); } uint closestFrame = _currentFrame; -- cgit v1.2.3