Added small memory and performance optimization.

This commit is contained in:
Eric Traut 2024-05-21 13:00:33 -07:00
parent be320a8b08
commit b93dc627fc

View File

@ -22510,30 +22510,32 @@ export function createTypeEvaluator(
}
}
const destErrorType = reportErrorsUsingObjType ? ClassType.cloneAsInstance(destType) : destType;
const srcErrorType = reportErrorsUsingObjType ? ClassType.cloneAsInstance(srcType) : srcType;
if (diag) {
const destErrorType = reportErrorsUsingObjType ? ClassType.cloneAsInstance(destType) : destType;
const srcErrorType = reportErrorsUsingObjType ? ClassType.cloneAsInstance(srcType) : srcType;
let destErrorTypeText = printType(destErrorType);
let srcErrorTypeText = printType(srcErrorType);
let destErrorTypeText = printType(destErrorType);
let srcErrorTypeText = printType(srcErrorType);
// If the text is the same, use the fully-qualified name rather than the short name.
if (destErrorTypeText === srcErrorTypeText && destType.details.fullName && srcType.details.fullName) {
destErrorTypeText = destType.details.fullName;
srcErrorTypeText = srcType.details.fullName;
}
// If the text is the same, use the fully-qualified name rather than the short name.
if (destErrorTypeText === srcErrorTypeText && destType.details.fullName && srcType.details.fullName) {
destErrorTypeText = destType.details.fullName;
srcErrorTypeText = srcType.details.fullName;
}
diag?.addMessage(
LocAddendum.typeIncompatible().format({
sourceType: srcErrorTypeText,
destType: destErrorTypeText,
})
);
diag?.addMessage(
LocAddendum.typeIncompatible().format({
sourceType: srcErrorTypeText,
destType: destErrorTypeText,
})
);
// Tell the user about the disableBytesTypePromotions if that is involved.
if (ClassType.isBuiltIn(destType, 'bytes')) {
const promotions = typePromotions.get(destType.details.fullName);
if (promotions && promotions.some((name) => name === srcType.details.fullName)) {
diag?.addMessage(LocAddendum.bytesTypePromotions());
// Tell the user about the disableBytesTypePromotions if that is involved.
if (ClassType.isBuiltIn(destType, 'bytes')) {
const promotions = typePromotions.get(destType.details.fullName);
if (promotions && promotions.some((name) => name === srcType.details.fullName)) {
diag?.addMessage(LocAddendum.bytesTypePromotions());
}
}
}