Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private bool StartsWithName(string input, string language)
- {
- foreach (var name in GetLocalNames(language))
- {
- if (!input.StartsWith(name, StringComparison.Ordinal))
- {
- continue;
- }
- if (name.Length + 1 == input.Length)
- {
- continue;
- }
- var charAfterName = input[name.Length];
- if (charAfterName == ' ' || charAfterName == ',' || charAfterName == ':')
- {
- return true;
- }
- }
- return false;
- IEnumerable<string> GetLocalNames(string lang)
- {
- if (_names == null)
- {
- var nameList = new NameList(Configuration.DictionariesDirectory, lang, Configuration.Settings.WordLists.UseOnlineNames, Configuration.Settings.WordLists.NamesUrl);
- _names = nameList.GetAllNames();
- }
- return _names ?? Enumerable.Empty<string>();
- }
- }
- private bool StartsWithName(string input, string language)
- {
- if (_names == null)
- {
- var nameList = new NameList(Configuration.DictionariesDirectory, language, Configuration.Settings.WordLists.UseOnlineNames, Configuration.Settings.WordLists.NamesUrl);
- _names = nameList.GetAllNames();
- if (_names == null)
- {
- return false;
- }
- }
- foreach (var name in _names)
- {
- // WARNING: THIS LINE IS CAUSING TOO MUCH SOH (SMALL OBJECT HEAP)
- if (input.StartsWith(name + " ", StringComparison.Ordinal) || input.StartsWith(name + ",", StringComparison.Ordinal) || input.StartsWith(name + ":", StringComparison.Ordinal))
- {
- return true;
- }
- }
- return false;
- }
- CONTEXT: SubtitleEdit - FixContinuationStyle.cs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement