From f4602de10805881d29e1a8c08d27e1df5a583f2b Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Sat, 15 Jun 2019 01:23:30 +0000 Subject: [PATCH] Cache the entire avatar_lib.js (in bbs.mods), not just the avatar data - performance optimization. --- exec/showavatar.js | 8 +++++--- exec/showfileavatar.js | 5 +++-- exec/showmsgavatar.js | 7 ++++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/exec/showavatar.js b/exec/showavatar.js index 6d2ccf7d14..3ae3a96d5e 100644 --- a/exec/showavatar.js +++ b/exec/showavatar.js @@ -28,10 +28,12 @@ for(var i in argv) { } } -var Avatar = load({}, 'avatar_lib.js'); +if(!bbs.mods.avatar_lib) + bbs.mods.avatar_lib = load({}, 'avatar_lib.js'); + if(draw) { - Avatar.draw(usernum, /* name: */null, /* netaddr: */null, above, right, top); + bbs.mods.avatar_lib.draw(usernum, /* name: */null, /* netaddr: */null, above, right, top); console.attributes = 7; // Clear the background attribute as the next line might scroll, filling with BG attribute } else { - Avatar.show(usernum); + bbs.mods.avatar_lib.show(usernum); } diff --git a/exec/showfileavatar.js b/exec/showfileavatar.js index 2a9949bd83..d1d3ac1199 100644 --- a/exec/showfileavatar.js +++ b/exec/showfileavatar.js @@ -5,7 +5,8 @@ require("userdefs.js", 'USER_ANSI'); // Avatar support here: if(!(bbs.file_attr&FM_ANON) && console.term_supports(USER_ANSI)) { - var Avatar = load({}, 'avatar_lib.js'); - Avatar.draw(null, bbs.file_uploader, null, /* above: */true, /* right-justified: */true); + if(!bbs.mods.avatar_lib) + bbs.mods.avatar_lib = load({}, 'avatar_lib.js'); + bbs.mods.avatar_lib.draw(null, bbs.file_uploader, null, /* above: */true, /* right-justified: */true); console.attributes = 7; // Clear the background attribute as the next line might scroll, filling with BG attribute } \ No newline at end of file diff --git a/exec/showmsgavatar.js b/exec/showmsgavatar.js index 1ca7ee1b95..f4db7b96ab 100644 --- a/exec/showmsgavatar.js +++ b/exec/showmsgavatar.js @@ -28,14 +28,15 @@ function draw_default_avatar(sub) if(!avatar) avatar = options.msg_default; if(avatar) - Avatar.draw_bin(avatar, /* above: */true, /* right-justified: */true, bbs.msghdr_top_of_screen); + bbs.mods.avatar_lib.draw_bin(avatar, /* above: */true, /* right-justified: */true, bbs.msghdr_top_of_screen); } // Avatar support here: if(!(bbs.msg_attr&MSG_ANONYMOUS) && (console.term_supports()&(USER_ANSI|USER_NO_EXASCII)) == USER_ANSI) { - var Avatar = load({}, 'avatar_lib.js'); - var success = Avatar.draw(bbs.msg_from_ext, bbs.msg_from, bbs.msg_from_net, /* above: */true, /* right-justified: */true + if(!bbs.mods.avatar_lib) + bbs.mods.avatar_lib = load({}, 'avatar_lib.js'); + var success = bbs.mods.avatar_lib.draw(bbs.msg_from_ext, bbs.msg_from, bbs.msg_from_net, /* above: */true, /* right-justified: */true ,bbs.msghdr_top_of_screen); if(!success && bbs.smb_sub_code) { draw_default_avatar(bbs.smb_sub_code); -- GitLab