danbev commited on
Commit
e4a0565
·
unverified ·
1 Parent(s): 6b8d348

whisper : fix grammar advance stack warning (#3087)

Browse files

This commit addresses a warnings that is present for Release builds:
```console
[ 30%] Building CXX object src/CMakeFiles/whisper.dir/whisper.cpp.o
In file included from /usr/include/c++/13/bits/stl_tree.h:63,
from /usr/include/c++/13/map:62,
from /home/danbev/work/ai/whisper.cpp/src/whisper-arch.h:5,
from /home/danbev/work/ai/whisper.cpp/src/whisper.cpp:2:
In static member function ‘static void std::__copy_move<false, false, std::random_access_iterator_tag>::__assign_one(_Tp*, _Up*) [with _Tp = const whisper_grammar_element*; _Up = const whisper_grammar_element* const]’,
inlined from ‘static _Up* std::__copy_move<_IsMove, true, std::random_access_iterator_tag>::__copy_m(_Tp*, _Tp*, _Up*) [with _Tp = const whisper_grammar_element* const; _Up = const whisper_grammar_element*; bool _IsMove = false]’ at /usr/include/c++/13/bits/stl_algobase.h:440:20,
inlined from ‘_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = false; _II = const whisper_grammar_element* const*; _OI = const whisper_grammar_element**]’ at /usr/include/c++/13/bits/stl_algobase.h:506:30,
inlined from ‘_OI std::__copy_move_a1(_II, _II, _OI) [with bool _IsMove = false; _II = const whisper_grammar_element* const*; _OI = const whisper_grammar_element**]’ at /usr/include/c++/13/bits/stl_algobase.h:533:42,
...
```
This warning is caused by the fact that the `stack` vector is empty
when it is passed to `new_stacks.push_back(stack);`.

The suggested fix is to use `new_stacks.emplace_back();` instead of
`new_stacks.push_back(stack);`.

Files changed (1) hide show
  1. src/whisper.cpp +1 -1
src/whisper.cpp CHANGED
@@ -4501,7 +4501,7 @@ static void whisper_grammar_advance_stack(
4501
  std::vector<std::vector<const whisper_grammar_element *>> & new_stacks) {
4502
 
4503
  if (stack.empty()) {
4504
- new_stacks.push_back(stack);
4505
  return;
4506
  }
4507
 
 
4501
  std::vector<std::vector<const whisper_grammar_element *>> & new_stacks) {
4502
 
4503
  if (stack.empty()) {
4504
+ new_stacks.emplace_back();
4505
  return;
4506
  }
4507