masaori335 commented on a change in pull request #8504:
URL: https://github.com/apache/trafficserver/pull/8504#discussion_r746126337
##########
File path: src/traffic_server/InkAPI.cc
##########
@@ -3262,43 +3262,24 @@ TSMimeHdrFieldCopyValues(TSMBuffer dest_bufp, TSMLoc
dest_hdr, TSMLoc dest_field
return TS_SUCCESS;
}
-// TODO: This is implemented horribly slowly, but who's using it anyway?
-// If we threaded all the MIMEFields, this function could be easier,
-// but we'd have to print dups in order and we'd need a flag saying
-// end of dup list or dup follows.
TSMLoc
TSMimeHdrFieldNext(TSMBuffer bufp, TSMLoc hdr, TSMLoc field)
{
sdk_assert(sdk_sanity_check_mbuffer(bufp) == TS_SUCCESS);
sdk_assert((sdk_sanity_check_mime_hdr_handle(hdr) == TS_SUCCESS) ||
(sdk_sanity_check_http_hdr_handle(hdr) == TS_SUCCESS));
sdk_assert(sdk_sanity_check_field_handle(field, hdr) == TS_SUCCESS);
- MIMEFieldSDKHandle *handle = (MIMEFieldSDKHandle *)field;
-
- if (handle->mh == nullptr) {
- return TS_NULL_MLOC;
- }
-
- int slotnum = mime_hdr_field_slotnum(handle->mh, handle->field_ptr);
- if (slotnum == -1) {
- return TS_NULL_MLOC;
- }
-
- while (true) {
- ++slotnum;
- MIMEField *f = mime_hdr_field_get_slotnum(handle->mh, slotnum);
Review comment:
Returning iterator looks great!
But I'm wondering about performance improvement. It looks like
`MIMEHdrImpl::iterator::operator++()` goes `step()` and does almost the same
search. Where is the shortcut?
https://github.com/apache/trafficserver/blob/664e80eaf392f36ece50cfc463bb22dc25117395/proxy/hdrs/MIME.cc#L1285-L1312
https://github.com/apache/trafficserver/blob/664e80eaf392f36ece50cfc463bb22dc25117395/proxy/hdrs/MIME.h#L351-L364
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]