Skip to content

Conversation

@karlseguin
Copy link
Collaborator

@karlseguin karlseguin commented Feb 8, 2025

1 - Use getOrPut to avoid making 2 map lookups where possible.

2 - Use an arena allocator for Values, which makes memory management simpler.

3 - Because of the arena, we no longer need to allocate key or values which don't need
to be unescaped. The downside is that the input string has to outlive the
query.Values (but I think this is currently always the case)

4 - Optimize unescape logic & allocations

5 - Improve test coverage

1 - Use getOrPut to avoid making 2 map lookups where possible.

2 - Use an arena allocator for Values, which makes memory management simpler.

3 - Because of lightpanda-io#2, we no longer need to allocate key or values which don't need
    to be unescaped. The downside is that the input string has to outlive the
    query.Values (but I think this is currently always the case)

4 - Optimize unescape logic & allocations

5 - Improve test coverage
@krichprollsch krichprollsch self-requested a review February 8, 2025 10:34
test "parse empty query" {
var values = try parseQuery(std.testing.allocator, "");
defer values.deinit();
// The return'd string may or may not be allocated. Callers should use arenas
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we change the allocator we pass to unescape in parseQuery to use the values's arena then?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YES! The test runner doesn't detect memory leaks when using std.testing.allocator right now (https://github.com/lightpanda-io/browser/pull/409)...would have caught that.

@karlseguin karlseguin closed this Feb 10, 2025
@karlseguin karlseguin deleted the url_query branch February 10, 2025 08:12
@github-actions github-actions bot locked and limited conversation to collaborators Feb 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants