Add ByID and ByToken to token.IDMap.

This commit is contained in:
Nigel Tao committed 2017-05-06 17:02:11 +10:00
1 parent f744089e9c
commit cf8167a648
4 files changed
+20 -17

No files matched your search

+3
View File
@@ -57,6 +57,9 @@ func (m *IDMap) ByName(name string) ID {
return 0
}
func (m *IDMap) ByID(x ID) string { return m.ByKey(Key(x >> KeyShift)) }
func (m *IDMap) ByToken(t Token) string { return m.ByKey(Key(t.ID >> KeyShift)) }
func (m *IDMap) ByKey(k Key) string {
if k < nBuiltInKeys {
return builtInsByKey[k].name