From 43e3dc7a9ee58e556eafa845bfe5645cafcd0f8d Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 22 Oct 2022 08:10:00 -0400 Subject: [PATCH] use inline insertion sort for short array --- src/REACTION/fix_bond_react.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/REACTION/fix_bond_react.cpp b/src/REACTION/fix_bond_react.cpp index bf931fadd1..87573040f7 100644 --- a/src/REACTION/fix_bond_react.cpp +++ b/src/REACTION/fix_bond_react.cpp @@ -1735,7 +1735,16 @@ void FixBondReact::inner_crosscheck_loop() // ...actually, avail_guesses should never be zero here anyway if (guess_branch[avail_guesses-1] == 0) guess_branch[avail_guesses-1] = num_choices; - std::sort(tag_choices, tag_choices + num_choices); + for (int i=1; i < num_choices; ++i) { + tagint hold = tag_choices[i]; + int j = i - 1; + while ((j >=0) && (tag_choices[j] > hold)) { + tag_choices[j+1] = tag_choices[j]; + --j; + } + tag_choices[j+1] = hold; + } + for (int i = guess_branch[avail_guesses-1]-1; i >= 0; i--) { int already_assigned = 0; for (int j = 0; j < onemol->natoms; j++) {