mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
binary serch when size > 16
This commit is contained in:
parent
2244e33943
commit
86686a99b9
2
port/linux/.vscode/launch.json
vendored
2
port/linux/.vscode/launch.json
vendored
@ -11,7 +11,7 @@
|
|||||||
"program": "${workspaceFolder}/build/test/pikascript_test",
|
"program": "${workspaceFolder}/build/test/pikascript_test",
|
||||||
// "program": "${workspaceFolder}/build/boot/demo06-pikamain/pikascript_demo06-pikamain",
|
// "program": "${workspaceFolder}/build/boot/demo06-pikamain/pikascript_demo06-pikamain",
|
||||||
"args": [
|
"args": [
|
||||||
"--gtest_filter=vm.c_module_get_set_attr"
|
// "--gtest_filter=vm.c_module_get_set_attr"
|
||||||
],
|
],
|
||||||
"stopAtEntry": false,
|
"stopAtEntry": false,
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
|
@ -331,47 +331,44 @@ Arg* _obj_getProp(PikaObj* obj, char* name) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Hash method_hash = hash_time33(name);
|
Hash method_hash = hash_time33(name);
|
||||||
#define BINARY_SEARCH_ENABLE 1
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (prop == NULL) {
|
if (prop == NULL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#if BINARY_SEARCH_ENABLE
|
|
||||||
/* binary search */
|
|
||||||
int size = prop->methodGroupCount;
|
int size = prop->methodGroupCount;
|
||||||
|
/* binary search */
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
goto next;
|
goto next;
|
||||||
}
|
}
|
||||||
int left = 0;
|
if (size > 16) {
|
||||||
int right = size - 1;
|
int left = 0;
|
||||||
int mid = 0;
|
int right = size - 1;
|
||||||
int i = 0;
|
int mid = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
i++;
|
if (left > right) {
|
||||||
if (left > right) {
|
break;
|
||||||
break;
|
}
|
||||||
|
mid = (right + left) >> 1;
|
||||||
|
Arg* prop_this = (Arg*)(prop->methodGroup + mid);
|
||||||
|
if (prop_this->name_hash == method_hash) {
|
||||||
|
method = prop_this;
|
||||||
|
goto exit;
|
||||||
|
} else if (prop_this->name_hash < method_hash) {
|
||||||
|
left = mid + 1;
|
||||||
|
} else {
|
||||||
|
right = mid - 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mid = (right + left) >> 1;
|
} else {
|
||||||
Arg* prop_this = (Arg*)(prop->methodGroup + mid);
|
for (int i = 0; i < (int)prop->methodGroupCount; i++) {
|
||||||
if (prop_this->name_hash == method_hash) {
|
Arg* prop_this = (Arg*)(prop->methodGroup + i);
|
||||||
method = prop_this;
|
if (prop_this->name_hash == method_hash) {
|
||||||
goto exit;
|
method = prop_this;
|
||||||
} else if (prop_this->name_hash < method_hash) {
|
goto exit;
|
||||||
left = mid + 1;
|
}
|
||||||
} else {
|
|
||||||
right = mid - 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
for (int i = 0; i < (int)prop->methodGroupCount; i++) {
|
|
||||||
Arg* prop_this = (Arg*)(prop->methodGroup + i);
|
|
||||||
if (prop_this->name_hash == method_hash) {
|
|
||||||
method = prop_this;
|
|
||||||
goto exit;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
goto next;
|
goto next;
|
||||||
#endif
|
|
||||||
next:
|
next:
|
||||||
prop = (NativeProperty*)prop->super;
|
prop = (NativeProperty*)prop->super;
|
||||||
}
|
}
|
||||||
|
@ -2,4 +2,4 @@
|
|||||||
#define PIKA_VERSION_MINOR 11
|
#define PIKA_VERSION_MINOR 11
|
||||||
#define PIKA_VERSION_MICRO 4
|
#define PIKA_VERSION_MICRO 4
|
||||||
|
|
||||||
#define PIKA_EDIT_TIME "2022/10/10 21:37:18"
|
#define PIKA_EDIT_TIME "2022/10/15 23:32:32"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user