From 08d3f6c3d1e0e0b27380d94d75593db4a11bbb4b Mon Sep 17 00:00:00 2001 From: Saxon Date: Thu, 15 Aug 2019 01:20:25 +0930 Subject: [PATCH] codec/h264/h264dec: made absi faster and more readable --- codec/h264/h264dec/helpers.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/codec/h264/h264dec/helpers.go b/codec/h264/h264dec/helpers.go index ae4c935d..4289f1f8 100644 --- a/codec/h264/h264dec/helpers.go +++ b/codec/h264/h264dec/helpers.go @@ -9,7 +9,6 @@ package h264dec import ( "errors" - "math" ) // binToSlice is a helper function to convert a string of binary into a @@ -57,6 +56,9 @@ func mini(a, b int) int { return b } -func absi(i int) int { - return int(math.Abs(float64(i))) +func absi(a int) int { + if a < 0 { + return -a + } + return a }