Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Unified Diff: mojom/mojom_parser/mojom/mojom_descriptor.go

Issue 1421193003: New Mojom Parser: Serialization. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Fix typos. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: mojom/mojom_parser/mojom/mojom_descriptor.go
diff --git a/mojom/mojom_parser/mojom/mojom_descriptor.go b/mojom/mojom_parser/mojom/mojom_descriptor.go
index 4ecac5fb01fa75d4122e2a846e18f348660629cd..12aff355cf4d820a32358b60dc14fb76217c28b5 100644
--- a/mojom/mojom_parser/mojom/mojom_descriptor.go
+++ b/mojom/mojom_parser/mojom/mojom_descriptor.go
@@ -474,14 +474,21 @@ func computeTypeKey(fullyQualifiedName string) (typeKey string) {
if typeKey, ok := fqnToTypeKey[fullyQualifiedName]; ok == true {
return typeKey
}
- typeKey = fmt.Sprintf("%d", nextKey)
- nextKey++
+ // TODO(rudominer) Until we understand better what the requirements are for a type key
+ // let's just use the reversed fully-qualified name as the type key. The reason
+ // for the reversal is pragmatic: When debugging we can tell whether a string
mattr 2015/11/10 19:26:49 Reversing seems an odd way to mark the name, you c
rudominer 2015/11/10 23:29:35 Good idea. Thanks. Done.
+ // is a type key or a fully-qualified-name
+ numBytes := len(fullyQualifiedName)
+ reversed := make([]byte, numBytes)
+ for i := 0; i < numBytes; i++ {
+ reversed[i] = fullyQualifiedName[numBytes-i-1]
+ }
+ typeKey = string(reversed)
fqnToTypeKey[fullyQualifiedName] = typeKey
return
}
var fqnToTypeKey map[string]string
-var nextKey int
func init() {
fqnToTypeKey = make(map[string]string)

Powered by Google App Engine
This is Rietveld 408576698