check values before index manipulation

It may speed up plotting a little bit

Change-Id: I731210b259a41cdbb79f4eeaf3981e6d0b2e5826
Reviewed-on: http://review.couchbase.org/31089
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Pavel Paulau <pavel.paulau@gmail.com>