Can you use CRM_Core_DAO::getFieldValue instead of CRM_Core_BAO_Extension::retrieve,
since you only need to know if the extension is active or not.