{"action":"opened","issue":{"url":"https://api.github.com/repos/ludocode/mpack/issues/30","labels_url":"https://api.github.com/repos/ludocode/mpack/issues/30/labels{/name}","comments_url":"https://api.github.com/repos/ludocode/mpack/issues/30/comments","events_url":"https://api.github.com/repos/ludocode/mpack/issues/30/events","html_url":"https://github.com/ludocode/mpack/issues/30","id":118607068,"number":30,"title":"Lowlevel pruning with reader","user":{"login":"xor-gate","id":1050166,"avatar_url":"https://avatars.githubusercontent.com/u/1050166?v=3","gravatar_id":"","url":"https://api.github.com/users/xor-gate","html_url":"https://github.com/xor-gate","followers_url":"https://api.github.com/users/xor-gate/followers","following_url":"https://api.github.com/users/xor-gate/following{/other_user}","gists_url":"https://api.github.com/users/xor-gate/gists{/gist_id}","starred_url":"https://api.github.com/users/xor-gate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xor-gate/subscriptions","organizations_url":"https://api.github.com/users/xor-gate/orgs","repos_url":"https://api.github.com/users/xor-gate/repos","events_url":"https://api.github.com/users/xor-gate/events{/privacy}","received_events_url":"https://api.github.com/users/xor-gate/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-11-24T13:20:35Z","updated_at":"2015-11-24T13:20:35Z","closed_at":null,"body":"Currently I extract a key : <map> to feed to a other piece of the API decoder and want to calculate the size in bytes of the map and the begin address. Here a example:\r\n\r\n```\r\n{ \r\n   \"somekey\" : 1,\r\n   \"anotherkey\" : \"value\",\r\n   \"interestedkey\" : {\r\n       \"subkey\" : \"awesomevalue\",\r\n       \"subkey1\" : true\r\n    },\r\n    \"foo\" : \"bar\"\r\n}\r\n```\r\n\r\nI itterate over the parent map and search for \"interestedkey\", then I pass the reader context to a function which calculates `const char *buffer, size_t size` for a new reader. \r\n\r\nCurrently I do in the extraction function:\r\n```\r\nstatic void di_rpc_deserialize_msg_params(mpack_reader_t *reader, struct di_rpc_msg *msg)\r\n{\r\n        const size_t keys = mpack_expect_map(reader);\r\n\r\n        if (mpack_reader_error(reader) != mpack_ok) {\r\n                msg->params.begin = NULL;\r\n                msg->params.end   = NULL;\r\n                return;\r\n        }\r\n\r\n        msg->params.begin = &reader->buffer[reader->pos - 1];\r\n\r\n        for (size_t n = 0; n < keys; n++) {\r\n                mpack_discard(reader);\r\n                mpack_discard(reader);\r\n        }\r\n\r\n        msg->params.end = &reader->buffer[reader->pos];\r\n\r\n        mpack_done_map(reader);\r\n}\r\n```\r\n\r\nOnly it feels very inefficient to itterate over all key-values and discard them. Is it valid to just rewind the reader context `pos` one byte (so it points to the map byte) and then discard from this point?"}}