diff options
author | Dominik Picheta <dominikpicheta@googlemail.com> | 2015-05-17 18:20:27 +0100 |
---|---|---|
committer | Dominik Picheta <dominikpicheta@googlemail.com> | 2015-05-17 18:20:27 +0100 |
commit | 60af6a265352d75559a98f1977084e9e5ab081fd (patch) | |
tree | 4ccff8441fd08e4ef4c711914f6a3e71b2146f9d | |
parent | d937b4cd850b3ee93815622609f7cd1d8a38d484 (diff) | |
parent | 46264a0674091a1838e403d44d02cb919fa7a661 (diff) | |
download | Nim-60af6a265352d75559a98f1977084e9e5ab081fd.tar.gz |
Merge pull request #2747 from def-/json-inline
Make a few json procs inline, improves performance significantly
-rw-r--r-- | lib/pure/json.nim | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/pure/json.nim b/lib/pure/json.nim index 4f7f11108..7d22e897b 100644 --- a/lib/pure/json.nim +++ b/lib/pure/json.nim @@ -761,7 +761,7 @@ proc len*(n: JsonNode): int = of JObject: result = n.fields.len else: discard -proc `[]`*(node: JsonNode, name: string): JsonNode = +proc `[]`*(node: JsonNode, name: string): JsonNode {.inline.} = ## Gets a field from a `JObject`, which must not be nil. ## If the value at `name` does not exist, returns nil assert(not isNil(node)) @@ -771,7 +771,7 @@ proc `[]`*(node: JsonNode, name: string): JsonNode = return item return nil -proc `[]`*(node: JsonNode, index: int): JsonNode = +proc `[]`*(node: JsonNode, index: int): JsonNode {.inline.} = ## Gets the node at `index` in an Array. Result is undefined if `index` ## is out of bounds assert(not isNil(node)) @@ -799,7 +799,7 @@ proc add*(obj: JsonNode, key: string, val: JsonNode) = assert obj.kind == JObject obj.fields.add((key, val)) -proc `[]=`*(obj: JsonNode, key: string, val: JsonNode) = +proc `[]=`*(obj: JsonNode, key: string, val: JsonNode) {.inline.} = ## Sets a field from a `JObject`. Performs a check for duplicate keys. assert(obj.kind == JObject) for i in 0..obj.fields.len-1: |