Skip to content

Commit fb137c0

Browse files
committed
Re-added optimisation when no search is made
1 parent 95b5d78 commit fb137c0

File tree

2 files changed

+31
-18
lines changed

2 files changed

+31
-18
lines changed

azul.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,15 +472,15 @@
472472
COMBINE_HIDPI_IMAGES = YES;
473473
DEFINES_MODULE = NO;
474474
DEVELOPMENT_TEAM = UD3V83TPY7;
475-
GCC_OPTIMIZATION_LEVEL = 0;
475+
GCC_OPTIMIZATION_LEVEL = fast;
476476
HEADER_SEARCH_PATHS = /usr/local/include;
477477
INFOPLIST_FILE = src/Info.plist;
478478
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
479479
LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/libs";
480480
PRODUCT_BUNDLE_IDENTIFIER = tudelft3d.azul;
481481
PRODUCT_NAME = "$(TARGET_NAME)";
482482
SWIFT_OBJC_BRIDGING_HEADER = "src/azul-Bridging-Header.h";
483-
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
483+
SWIFT_OPTIMIZATION_LEVEL = "-O";
484484
SWIFT_VERSION = 4.0;
485485
};
486486
name = Debug;

src/DataManager/DataManager.cpp

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -631,26 +631,39 @@ bool DataManager::matchesSearch(AzulObject &object) {
631631
}
632632

633633
bool DataManager::isExpandable(AzulObject &object) {
634-
for (auto &child: object.children) {
635-
if (matchesSearch(child)) return true;
636-
} return false;
634+
if (searchString.empty()) {
635+
if (!object.children.empty()) return true;
636+
return false;
637+
} else {
638+
for (auto &child: object.children) {
639+
if (matchesSearch(child)) return true;
640+
} return false;
641+
}
637642
}
638643

639644
int DataManager::numberOfChildren(AzulObject &object) {
640-
int matchingChildren = 0;
641-
for (auto &child: object.children) {
642-
if (matchesSearch(child)) ++matchingChildren;
643-
} return matchingChildren;
645+
if (searchString.empty()) {
646+
return (int)object.children.size();
647+
} else {
648+
int matchingChildren = 0;
649+
for (auto &child: object.children) {
650+
if (matchesSearch(child)) ++matchingChildren;
651+
} return matchingChildren;
652+
}
644653
}
645654

646655
std::vector<AzulObject>::iterator DataManager::child(AzulObject &object, long index) {
647-
int matchingChildren = 0;
648-
for (std::vector<AzulObject>::iterator child = object.children.begin();
649-
child != object.children.end();
650-
++child) {
651-
if (matchesSearch(*child)) {
652-
if (matchingChildren == index) return child;
653-
++matchingChildren;
654-
}
655-
} return object.children.begin();
656+
if (searchString.empty()) {
657+
return object.children.begin()+index;
658+
} else {
659+
int matchingChildren = 0;
660+
for (std::vector<AzulObject>::iterator child = object.children.begin();
661+
child != object.children.end();
662+
++child) {
663+
if (matchesSearch(*child)) {
664+
if (matchingChildren == index) return child;
665+
++matchingChildren;
666+
}
667+
} return object.children.begin();
668+
}
656669
}

0 commit comments

Comments
 (0)