-
Notifications
You must be signed in to change notification settings - Fork 1
/
__apollo_get_module_text
62 lines (48 loc) · 1.62 KB
/
__apollo_get_module_text
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# vim:ft=zsh
__apollo_get_module_text() {
local module side
local -i line num
local start
local cache_key cache_status
local -a cache
line="$1"
side="$2"
module="$3"
num="$4"
if [[ "$profiler" == "yes" ]]; then
start=${EPOCHREALTIME}
fi
if (( __APOLLO_ASYNC == 1 && ${+functions[__apollo_${module}_always_async]} )); then
async_job apollo_async_helper \
"__apollo_${module}_async_runner" \
"__apollo_${module}_always_async" \
":apollo:${APOLLO_THEME}:${line}:${side}:${module}" 2> /dev/null \
|| __apollo_start_async
fi
if ((${+functions[__apollo_${module}_cache_key]})); then
"__apollo_${module}_cache_key";
cache_key="${APOLLO_THEME}-${line}-${side}-${num}-${__APOLLO_RETURN_MESSAGE}"
cache=("${(s.\0.)__APOLLO_MODULE_CACHE["${cache_key}"]}")
fi
if [[ -n "$cache" ]]; then
__APOLLO_MODULE_TEXT[$num]="${cache[2]}"
__APOLLO_MODULE_HAS_LENGTH[$num]="${cache[1]}"
__APOLLO_MODULE_MODE[$module]="${cache[3]}"
cache_status="HIT"
else
if (( __APOLLO_ASYNC == 1 && ${+functions[__apollo_${module}_async]} )); then
async_job apollo_async_helper \
"__apollo_${module}_async_runner" \
"__apollo_${module}_async" \
":apollo:${APOLLO_THEME}:${line}:${side}:${module}" 2> /dev/null \
|| __apollo_start_async
fi
__APOLLO_MODULE_MODE[$module]="default"
__apollo_run_module "$line" "$side" "$module" "$num" "$cache_key"
cache_status="MISS"
fi
if [[ "$profiler" == "yes" ]]; then
printf "%25s: %f %s\n" "$module" "$((EPOCHREALTIME - start))" "$cache_status"
fi
}
__apollo_get_module_text "$@"