Skip to content

Commit

Permalink
Re-added optimisation when no search is made
Browse files Browse the repository at this point in the history
  • Loading branch information
kenohori committed Oct 12, 2017
1 parent 95b5d78 commit fb137c0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 18 deletions.
4 changes: 2 additions & 2 deletions azul.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -472,15 +472,15 @@
COMBINE_HIDPI_IMAGES = YES;
DEFINES_MODULE = NO;
DEVELOPMENT_TEAM = UD3V83TPY7;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_OPTIMIZATION_LEVEL = fast;
HEADER_SEARCH_PATHS = /usr/local/include;
INFOPLIST_FILE = src/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/libs";
PRODUCT_BUNDLE_IDENTIFIER = tudelft3d.azul;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "src/azul-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_VERSION = 4.0;
};
name = Debug;
Expand Down
45 changes: 29 additions & 16 deletions src/DataManager/DataManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,26 +631,39 @@ bool DataManager::matchesSearch(AzulObject &object) {
}

bool DataManager::isExpandable(AzulObject &object) {
for (auto &child: object.children) {
if (matchesSearch(child)) return true;
} return false;
if (searchString.empty()) {
if (!object.children.empty()) return true;
return false;
} else {
for (auto &child: object.children) {
if (matchesSearch(child)) return true;
} return false;
}
}

int DataManager::numberOfChildren(AzulObject &object) {
int matchingChildren = 0;
for (auto &child: object.children) {
if (matchesSearch(child)) ++matchingChildren;
} return matchingChildren;
if (searchString.empty()) {
return (int)object.children.size();
} else {
int matchingChildren = 0;
for (auto &child: object.children) {
if (matchesSearch(child)) ++matchingChildren;
} return matchingChildren;
}
}

std::vector<AzulObject>::iterator DataManager::child(AzulObject &object, long index) {
int matchingChildren = 0;
for (std::vector<AzulObject>::iterator child = object.children.begin();
child != object.children.end();
++child) {
if (matchesSearch(*child)) {
if (matchingChildren == index) return child;
++matchingChildren;
}
} return object.children.begin();
if (searchString.empty()) {
return object.children.begin()+index;
} else {
int matchingChildren = 0;
for (std::vector<AzulObject>::iterator child = object.children.begin();
child != object.children.end();
++child) {
if (matchesSearch(*child)) {
if (matchingChildren == index) return child;
++matchingChildren;
}
} return object.children.begin();
}
}

0 comments on commit fb137c0

Please sign in to comment.