[Filter/TFLite] make better the inefficient code
authorHyoungjooAhn <hello.ahnn@gmail.com>
Fri, 26 Oct 2018 01:17:05 +0000 (10:17 +0900)
committerMyungJoo Ham <myungjoo.ham@gmail.com>
Fri, 26 Oct 2018 10:35:30 +0000 (11:35 +0100)
get the length of vector before the iteration

Signed-off-by: HyoungjooAhn <hello.ahnn@gmail.com>
gst/tensor_filter/tensor_filter_tensorflow_lite_core.cc

index 0bbbdc3..79ea3a4 100644 (file)
@@ -332,7 +332,8 @@ TFLiteCore::invoke (const GstTensorMemory * input, GstTensorMemory * output)
   }
 
   /** if it is not `nullptr`, tensorflow makes `free()` the memory itself. */
-  for (int i = 0; i < tensors_idx.size (); ++i) {
+  int tensorSize = tensors_idx.size ();
+  for (int i = 0; i < tensorSize; ++i) {
     interpreter->tensor (tensors_idx[i])->data.raw = nullptr;
   }