lazily initialize /datum/element/weapon_description on examine (#92489)

## About The Pull Request

currently, `/datum/element/weapon_description` is added during every
single item init, even tho it only ever affects examines. i noticed
while looking at tracy traces downstream that it spent a bit much time
adding the weapon description, so why not just lazily initialize it
during examine instead?

direct port of the same thing from
https://github.com/Monkestation/Monkestation2.0/pull/7502

## Why It's Good For The Game

less wasted time during item init

## Changelog
🆑
code: Item weapon description elements are now initialized when first
examined, instead of immediately upon initialization.
/🆑
This commit is contained in:
Lucy
2025-08-11 14:23:24 -04:00
committed by nevimer
parent b2a28a2dbf
commit 7497b05ab1
2 changed files with 9 additions and 2 deletions
+7 -2
View File
@@ -284,8 +284,6 @@
if(damtype == BRUTE)
hitsound = SFX_SWING_HIT
add_weapon_description()
SEND_GLOBAL_SIGNAL(COMSIG_GLOB_NEW_ITEM, src)
setup_reskinning()
@@ -499,6 +497,13 @@
/obj/item/examine_descriptor(mob/user)
return "item"
/obj/item/examine(mob/user)
// lazily initialize the weapon description element if it hasn't been already
if(!(item_flags & WEAPON_DESCRIPTION_INITIALIZED))
add_weapon_description()
item_flags |= WEAPON_DESCRIPTION_INITIALIZED
return ..()
/obj/item/examine_more(mob/user)
. = ..()
if(HAS_TRAIT(user, TRAIT_RESEARCH_SCANNER))