Speed up boot times and Improve Json (De)Serialization performance and reduce memory usage by reusing JsonSerializerSettings (#9670)
(cherry picked from commit 75ee3b9622)
This commit is contained in:
@@ -253,19 +253,20 @@ namespace Umbraco.Web
|
||||
ImageCropRatioMode? ratioMode = null,
|
||||
bool upScale = true) => ImageCropperTemplateCoreExtensions.GetCropUrl(imageUrl, Current.ImageUrlGenerator, cropDataSet, width, height, cropAlias, quality, imageCropMode, imageCropAnchor, preferFocalPoint, useCropDimensions, cacheBusterValue, furtherOptions, ratioMode, upScale);
|
||||
|
||||
private static readonly JsonSerializerSettings ImageCropperValueJsonSerializerSettings = new JsonSerializerSettings
|
||||
{
|
||||
Culture = CultureInfo.InvariantCulture,
|
||||
FloatParseHandling = FloatParseHandling.Decimal
|
||||
};
|
||||
|
||||
internal static ImageCropperValue DeserializeImageCropperValue(this string json)
|
||||
{
|
||||
var imageCrops = new ImageCropperValue();
|
||||
ImageCropperValue imageCrops = null;
|
||||
if (json.DetectIsJson())
|
||||
{
|
||||
try
|
||||
{
|
||||
imageCrops = JsonConvert.DeserializeObject<ImageCropperValue>(json, new JsonSerializerSettings
|
||||
{
|
||||
Culture = CultureInfo.InvariantCulture,
|
||||
FloatParseHandling = FloatParseHandling.Decimal
|
||||
});
|
||||
imageCrops = JsonConvert.DeserializeObject<ImageCropperValue>(json, ImageCropperValueJsonSerializerSettings);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -273,6 +274,7 @@ namespace Umbraco.Web
|
||||
}
|
||||
}
|
||||
|
||||
imageCrops = imageCrops ?? new ImageCropperValue();
|
||||
return imageCrops;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user