mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-15 18:08:53 -07:00
5012c09368
| Method | Mean | Error | StdDev | Gen 0 | Allocated | |----------------------------- |---------:|--------:|--------:|-------:|----------:| | Old | 795.1 ns | 5.90 ns | 4.61 ns | 0.0029 | 312 B | | HashDataInsteadOfComputeHash | 396.1 ns | 1.36 ns | 1.13 ns | 0.0014 | 152 B | | StackallocedDestination | 395.8 ns | 1.80 ns | 1.60 ns | 0.0014 | 152 B | | RentBuffer | 498.8 ns | 3.35 ns | 2.97 ns | - | 40 B | Tested multiple possible speedups, in the end the simplest of them all won
39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using System;
|
|
using System.Security.Cryptography;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
|
|
namespace MediaBrowser.Common.Extensions
|
|
{
|
|
/// <summary>
|
|
/// Class BaseExtensions.
|
|
/// </summary>
|
|
public static class BaseExtensions
|
|
{
|
|
/// <summary>
|
|
/// Strips the HTML.
|
|
/// </summary>
|
|
/// <param name="htmlString">The HTML string.</param>
|
|
/// <returns><see cref="string" />.</returns>
|
|
public static string StripHtml(this string htmlString)
|
|
{
|
|
// http://stackoverflow.com/questions/1349023/how-can-i-strip-html-from-text-in-net
|
|
const string Pattern = @"<(.|\n)*?>";
|
|
|
|
return Regex.Replace(htmlString, Pattern, string.Empty).Trim();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the Md5.
|
|
/// </summary>
|
|
/// <param name="str">The string.</param>
|
|
/// <returns><see cref="Guid" />.</returns>
|
|
public static Guid GetMD5(this string str)
|
|
{
|
|
#pragma warning disable CA5351
|
|
return new Guid(MD5.HashData(Encoding.Unicode.GetBytes(str)));
|
|
#pragma warning restore CA5351
|
|
}
|
|
}
|
|
}
|