Optimizing iteration

prefix ++i is faster than post i++
This commit is contained in:
Bruno
2021-04-18 11:38:03 +02:00
parent 8389010002
commit c6d01c1420
19 changed files with 84 additions and 77 deletions

View File

@@ -197,7 +197,7 @@ void GeometryView::draw()
std::vector<Node *> surfaces;
std::vector<Node *> overlays;
for (auto source_iter = Mixer::manager().session()->begin();
source_iter != Mixer::manager().session()->end(); source_iter++) {
source_iter != Mixer::manager().session()->end(); ++source_iter) {
// if it is in the current workspace
if ((*source_iter)->workspace() == Settings::application.current_workspace) {
// will draw its surface
@@ -320,7 +320,7 @@ void GeometryView::draw()
// batch manipulation of sources in Geometry view
if (ImGui::Selectable( ICON_FA_EXPAND " Fit all" )){
for (auto sit = Mixer::selection().begin(); sit != Mixer::selection().end(); sit++){
for (auto sit = Mixer::selection().begin(); sit != Mixer::selection().end(); ++sit){
(*sit)->group(mode_)->scale_ = glm::vec3(output_surface_->scale_.x/ (*sit)->frame()->aspectRatio(), 1.f, 1.f);
(*sit)->group(mode_)->rotation_.z = 0;
(*sit)->group(mode_)->translation_ = glm::vec3(0.f);
@@ -330,7 +330,7 @@ void GeometryView::draw()
}
if (ImGui::Selectable( ICON_FA_VECTOR_SQUARE " Reset all" )){
// apply to every sources in selection
for (auto sit = Mixer::selection().begin(); sit != Mixer::selection().end(); sit++){
for (auto sit = Mixer::selection().begin(); sit != Mixer::selection().end(); ++sit){
(*sit)->group(mode_)->scale_ = glm::vec3(1.f);
(*sit)->group(mode_)->rotation_.z = 0;
(*sit)->group(mode_)->crop_ = glm::vec3(1.f);
@@ -352,7 +352,7 @@ void GeometryView::draw()
}
if (ImGui::Selectable( ICON_FA_COMPASS " Align" )){
// apply to every sources in selection
for (auto sit = Mixer::selection().begin(); sit != Mixer::selection().end(); sit++){
for (auto sit = Mixer::selection().begin(); sit != Mixer::selection().end(); ++sit){
(*sit)->group(mode_)->rotation_.z = overlay_selection_->rotation_.z;
(*sit)->touch();
}
@@ -414,7 +414,7 @@ std::pair<Node *, glm::vec2> GeometryView::pick(glm::vec2 P)
// find if the current source was picked
auto itp = pv.rbegin();
for (; itp != pv.rend(); itp++){
for (; itp != pv.rend(); ++itp){
// test if source contains this node
Source::hasNode is_in_source((*itp).first );
if ( is_in_source( current ) ){
@@ -452,7 +452,7 @@ std::pair<Node *, glm::vec2> GeometryView::pick(glm::vec2 P)
pick = { nullptr, glm::vec2(0.f) };
// loop over all nodes picked to detect clic on locks
for (auto itp = pv.rbegin(); itp != pv.rend(); itp++){
for (auto itp = pv.rbegin(); itp != pv.rend(); ++itp){
// get if a source was picked
Source *s = Mixer::manager().findSource((*itp).first);
// lock icon of a source (not current) is picked : unlock
@@ -466,7 +466,7 @@ std::pair<Node *, glm::vec2> GeometryView::pick(glm::vec2 P)
if ( pick.first == nullptr) {
// loop over all nodes picked
for (auto itp = pv.rbegin(); itp != pv.rend(); itp++){
for (auto itp = pv.rbegin(); itp != pv.rend(); ++itp){
// get if a source was picked
Source *s = Mixer::manager().findSource((*itp).first);
// accept picked sources in current workspaces
@@ -518,7 +518,7 @@ bool GeometryView::canSelect(Source *s) {
void GeometryView::applySelectionTransform(glm::mat4 M)
{
for (auto sit = Mixer::selection().begin(); sit != Mixer::selection().end(); sit++){
for (auto sit = Mixer::selection().begin(); sit != Mixer::selection().end(); ++sit){
// recompute all from matrix transform
glm::mat4 transform = M * (*sit)->stored_status_->transform_;
glm::vec3 tra, rot, sca;
@@ -1010,7 +1010,7 @@ void GeometryView::terminate()
// restore of all handles overlays
glm::vec2 c(0.f, 0.f);
for (auto sit = Mixer::manager().session()->begin();
sit != Mixer::manager().session()->end(); sit++){
sit != Mixer::manager().session()->end(); ++sit){
(*sit)->handles_[mode_][Handles::RESIZE]->overlayActiveCorner(c);
(*sit)->handles_[mode_][Handles::RESIZE_H]->overlayActiveCorner(c);
@@ -1038,7 +1038,7 @@ void GeometryView::arrow (glm::vec2 movement)
bool first = true;
glm::vec3 delta_translation(0.f);
for (auto it = Mixer::selection().begin(); it != Mixer::selection().end(); it++) {
for (auto it = Mixer::selection().begin(); it != Mixer::selection().end(); ++it) {
// individual move with SHIFT
if ( !Source::isCurrent(*it) && UserInterface::manager().shiftModifier() )