Vixen
02b45cc4
csharp
public readonly record struct Symbol

An interned name: four bytes that compare as fast as an integer, because they are one.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

A hash of the name rather than an index into a table, and the reason is determinism. An index assigned in first-seen order depends on what a process happened to load first, so two machines running the same build would assign different numbers to the same word — and a selection that breaks a tie on a number would then pick differently on each of them. [16](../../../docs/plan/16-networking.md) makes that a desync rather than a curiosity. A hash is the same everywhere, for ever, with no table to ship and no order to agree on.

⚠ 32 bits collide, and the bake is where that is caught. Two words in one vocabulary hashing alike would silently make them the same word. MoveSet's builder checks the whole vocabulary of a set for it and refuses, which turns a one-in-fifty-thousand mystery into a build error naming both words. The alternative — 64 bits — doubles the size of every facet to avoid a case the build can simply detect.

Names are kept for diagnostics only. ToString resolves through a process-wide table filled as symbols are created, so a debugger and an error message can say gait rather than 0x4f9a2b1c. Nothing in a frame reads it, and a symbol that arrived from a deserialised set with no name still compares correctly.

Fields and properties (3)

  • public uint Id

    The hash. Zero is the empty symbol and matches nothing.

  • public static Symbol None

    The symbol that is not a word. Matches nothing, including itself in a facet.

  • public bool IsSome

    Whether this is a real word.

Methods (4)

  • public Symbol(uint Id)

    An interned name: four bytes that compare as fast as an integer, because they are one.

  • public static Symbol Intern(string? name)

    Interns a name.

  • public bool TryGetCollision(out string first, out string second)

    Whether two different words this process has interned share this symbol.

  • public override string ToString()

    The name this was interned from, if this process has seen it.

Used by (60, showing 40)

  • ConstraintStageBenchmarksVixen.Benchmarks.Animation
  • ActiveHandlesVixen.Animation
  • AnimationParametersVixen.Animation
  • AttachmentFrameVixen.Animation
  • AttachmentSocketVixen.Animation
  • AttachmentSocketsVixen.Animation
  • AuthoringTestsVixen.Animation.Tests
  • ComputedTestBindingVixen.Animation.Tests
  • ConstraintBindingsVixen.Animation
  • ConstraintFrameRecordVixen.Animation
  • ConstraintGizmosVixen.Animation
  • ConstraintGoalVixen.Animation
  • ConstraintLabelsVixen.Animation
  • ConstraintProposalVixen.Animation
  • ConstraintProposalsVixen.Animation
  • ConstraintStackVixen.Animation
  • ConstraintTagRecordVixen.Animation
  • ConstraintTestsVixen.Animation.Tests
  • EntityFrameVixen.Animation
  • EnumeratorVixen.Animation
  • FacetVixen.Animation
  • FacetSetVixen.Animation
  • FootPlacementPresetVixen.Animation
  • GizmoTestsVixen.Animation.Tests
  • GroundVariationVixen.Animation
  • HarnessSubjectVixen.Animation
  • IBindingSourceVixen.Animation
  • MoveEntryVixen.Animation
  • MoveRoleVixen.Animation
  • MoveSetVixen.Animation
  • MoveSetTestsVixen.Animation.Tests
  • PropVariationVixen.Animation
  • ProvidedFrameVixen.Animation
  • ProxyShapeVixen.Animation
  • ProxyShapeSetVixen.Animation
  • ProxyShapeSetContentVixen.Animation
  • ProxyShapeTestsVixen.Animation.Tests
  • ProxyShapesVixen.Animation
  • ShapeClassVixen.Animation
  • ShapeClassMemberVixen.Animation