Skip to content

Commit

Permalink
Upgraded path-matcher to v1.1.4, used explicit casts in multivalue_map.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewlalis committed Feb 13, 2024
1 parent 6e013d2 commit ebfc9d2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"httparsed": "~>1.2.1",
"slf4d": "~>3",
"streams": "~>3",
"path-matcher": "~>1.1.3"
"path-matcher": "~>1.1.4"
},
"description": "Extremely lightweight HTTP server for D.",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion dub.selections.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"fileVersion": 1,
"versions": {
"httparsed": "1.2.1",
"path-matcher": "1.1.3",
"path-matcher": "1.1.4",
"slf4d": "3.0.0",
"streams": "3.5.0"
}
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/speed-test/dub.selections.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"cachetools": "0.4.1",
"handy-httpd": {"path":"../../"},
"httparsed": "1.2.1",
"path-matcher": "1.1.3",
"path-matcher": "1.1.4",
"requests": "2.1.3",
"slf4d": "3.0.0",
"streams": "3.5.0",
Expand Down
13 changes: 7 additions & 6 deletions source/handy_httpd/components/multivalue_map.d
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ struct MultiValueMap(KeyType, ValueType, alias KeySort = (a, b) => a < b) {
private Optional!Entry getEntry(KeyType k) {
long idx = indexOf(k);
if (idx == -1) return Optional!Entry.empty();
return Optional!Entry.of(entries[idx]);
return Optional!Entry.of(entries[cast(size_t) idx]);
}

/**
Expand Down Expand Up @@ -120,7 +120,7 @@ struct MultiValueMap(KeyType, ValueType, alias KeySort = (a, b) => a < b) {
ValueType[] getAll(KeyType k) const {
long idx = indexOf(k);
if (idx == -1) return [];
return entries[idx].values.dup;
return entries[cast(size_t) idx].values.dup;
}

/**
Expand All @@ -134,7 +134,7 @@ struct MultiValueMap(KeyType, ValueType, alias KeySort = (a, b) => a < b) {
Optional!ValueType getFirst(KeyType k) const {
long idx = indexOf(k);
if (idx == -1) return Optional!ValueType.empty();
return Optional!ValueType.of(entries[idx].values[0]);
return Optional!ValueType.of(entries[cast(size_t) idx].values[0]);
}

/**
Expand All @@ -151,7 +151,7 @@ struct MultiValueMap(KeyType, ValueType, alias KeySort = (a, b) => a < b) {
import std.algorithm.sorting : sort;
sort!((a, b) => KeySort(a.key, b.key))(entries);
} else {
entries[idx].values ~= v;
entries[cast(size_t) idx].values ~= v;
}
}

Expand All @@ -176,7 +176,8 @@ struct MultiValueMap(KeyType, ValueType, alias KeySort = (a, b) => a < b) {
return;
}
if (idx + 1 < entries.length) {
entries[idx .. $ - 1] = entries[idx + 1 .. $];
const i = cast(size_t) idx;
entries[i .. $ - 1] = entries[i + 1 .. $];
}
entries.length = entries.length - 1;
}
Expand Down Expand Up @@ -248,7 +249,7 @@ struct MultiValueMap(KeyType, ValueType, alias KeySort = (a, b) => a < b) {
if (idx == -1) {
entryAppender ~= Entry(k, [v]);
} else {
m.entries[idx].values ~= v;
m.entries[cast(size_t) idx].values ~= v;
}
return this;
}
Expand Down

0 comments on commit ebfc9d2

Please sign in to comment.