util: refine hg_mem_get_page_size
Avoid querying pagesize every time
long
hg_mem_get_page_size(void)
{
- long page_size;
+ static long page_size = 0;
+ if (page_size == 0) {
#ifdef _WIN32
SYSTEM_INFO system_info;
GetSystemInfo(&system_info);
@@ -38,6 +39,7 @@ hg_mem_get_page_size(void)
#else
page_size = sysconf(_SC_PAGE_SIZE);
#endif
+ }
return page_size;
}
