MetadataStringComparer 構造体
定義
可能な場合は割り当てを回避しながら、メタデータ内のクエリ文字列に文字列比較ヘルパーを提供します。Provides string comparison helpers to query strings in metadata while avoiding allocation if possible.
public value class MetadataStringComparer
public struct MetadataStringComparer
type MetadataStringComparer = struct
Public Structure MetadataStringComparer
- 継承
注釈
ハンドル引数と値引数の両方に非 ASCII テキストが含まれている場合を除き、割り当ては実行されません。No allocation is performed unless both the handle argument and the value argument contain non-ASCII text.
を使用してインスタンスを取得 StringComparer します。Obtain instances using StringComparer. 既定で初期化されたインスタンスは役に立たないので、参照として動作し null
ます。A default-initialized instance is useless and behaves as a null
reference.
このコードは最適化されているため、ローカルに割り当てるよりも比較子を再取得する際に追加のオーバーヘッドが発生することはありません。The code is optimized so that there is no additional overhead in re-obtaining a comparer over assigning it to a local. つまり、次のようなコンストラクトがあるとします。That is to say that a construct like:
if (reader.StringComparer.Equals(typeDef.Namespace, "System") && reader.StringComparer.Equals(typeDef.Name, "Object")
{
/* found System.Object */
}
次の値よりも効率的ではない:is no less efficient than:
var comparer = reader.StringComparer;
if (comparer.Equals(typeDef.Namespace, "System") && comparer.Equals(typeDef.Name, "Object")
{
/* found System.Object */
}
そのため、どちらを選択するかはスタイルの1つであり、パフォーマンスには適していません。The choice between them is therefore one of style and not performance.