~sircmpwn/public-inbox

hare: encoding::json: fix iterator next v1 PROPOSED

Patrick Widmer: 1
 encoding::json: fix iterator next

 1 files changed, 3 insertions(+), 1 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/public-inbox/patches/32220/mbox | git am -3
Learn more about email & git

[PATCH hare] encoding::json: fix iterator next Export this patch

Signed-off-by: Patrick Widmer <patrick.widmer@tbwnet.ch>
---
This is my first patch to hare and also the first patch submitted using
git send-email.

Let me know if there is a better way of fixing the issue at hand.
 encoding/json/value.ha | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/encoding/json/value.ha b/encoding/json/value.ha
index 486be438..8fd1f642 100644
--- a/encoding/json/value.ha
+++ b/encoding/json/value.ha
@@ -75,11 +75,13 @@ export fn iter(obj: *object) iterator = {
export fn next(iter: *iterator) ((const str, const *value) | void) = {
	for (iter.i < len(iter.obj.buckets); iter.i += 1) {
		const bucket = &iter.obj.buckets[iter.i];
		for (iter.j < len(bucket); iter.j += 1) {
		for (iter.j < len(bucket)) {
			const key = bucket[iter.j].0;
			const val = &bucket[iter.j].1;
			iter.j += 1;
			return (key, val);
		};
		iter.j = 0;
	};
};

-- 
2.36.1