mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-04-21 14:37:49 -05:00
Add string extension methods
This commit is contained in:
parent
5fd62ce61a
commit
433c04acd0
|
|
@ -72,5 +72,42 @@ namespace UniGLTF
|
|||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
// https://docs.unity3d.com/Manual/BestPracticeUnderstandingPerformanceInUnity5.html
|
||||
public static bool FastStartsWith(this string a, string b)
|
||||
{
|
||||
var aLen = a.Length;
|
||||
var bLen = b.Length;
|
||||
if (aLen < bLen)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var p = 0;
|
||||
while (p < bLen && a[p] == b[p])
|
||||
{
|
||||
++p;
|
||||
}
|
||||
|
||||
return p == bLen;
|
||||
}
|
||||
|
||||
public static bool FastEndsWith(this string a, string b)
|
||||
{
|
||||
var aLen = a.Length;
|
||||
var bLen = b.Length;
|
||||
if (aLen < bLen)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var p = 1;
|
||||
while (p <= bLen && a[aLen - p] == b[bLen - p])
|
||||
{
|
||||
++p;
|
||||
}
|
||||
|
||||
return p - 1 == bLen;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user