Skip to content

Remove unused URL helper functions#8170

Closed
shinrich wants to merge 2 commits intoapache:masterfrom
shinrich:remove-unused-url-helper-functions
Closed

Remove unused URL helper functions#8170
shinrich wants to merge 2 commits intoapache:masterfrom
shinrich:remove-unused-url-helper-functions

Conversation

@shinrich
Copy link
Member

No description provided.

@shinrich shinrich added this to the 10.0.0 milestone Jul 22, 2021
@shinrich shinrich self-assigned this Jul 22, 2021
@shinrich
Copy link
Member Author

[approve ci autest]

@maskit
Copy link
Member

maskit commented Jul 26, 2021

We might want to call those functions from URL class' getters, instead of having the code in the getters. That's what we do for the setters, although I don't know why we need URL and URLImpl.

@SolidWallOfCode
Copy link
Member

I think that should be a separate PR - at this point, if these are not used, it's reasonably to just KIWF.

@maskit
Copy link
Member

maskit commented Jul 28, 2021

Remove the functions on this PR, and then reimplement exactly the same functions on next PR to call them from URL class? That doesn't make sense. If you're going that way, I'm going to be -1 on this PR and create "a separate PR" to avoid reimplementing the functions.

This is what you are removing

const char *
url_user_get(URLImpl *url, int *length)
{
*length = url->m_len_user;
return url->m_ptr_user;
}

These are what we have in a different place

inline const char *
URL::user_get(int *length)
{
ink_assert(valid());
*length = m_url_impl->m_len_user;
return m_url_impl->m_ptr_user;
}

inline void
URL::user_set(const char *value, int length)
{
ink_assert(valid());
url_user_set(m_heap, m_url_impl, value, length, true);
}

@shinrich
Copy link
Member Author

shinrich commented Aug 4, 2021

So I started to pull the url_*_set functions into the URL methods, but those free functions are also used else where.

The url_get functions are not called from anywhere. So I think this PR as it stands is useful. Removing unused functions. Making the URL set methods symmetric is not beneficial since the url_set free functions will exist in any case.

@maskit
Copy link
Member

maskit commented Aug 5, 2021

So I started to pull the url_*_set functions into the URL methods, but those free functions are also used else where.

That is not what I'm suggesting. url_*_set functions are ok as they are.

The url_get functions are not called from anywhere. So I think this PR as it stands is useful. Removing unused functions.

I'm suggesting to use those url_*_get functions in URL class' methods.

inline const char * 
URL::user_get(int *length) 
{ 
  ink_assert(valid()); 
  return url_user_get(m_url_impl, length);
} 

No dup code, no unused code, no detail exposure, and no inconsistency. And once we do this, making all the free functions to URLImpl's methods is probably just a couple of regex operations since the first parameter is a pointer for URLImpl instance.

I think this is the right direction, because I'd have to add back the unused functions to achieve no detail exposure and no inconsistency if you remove the functions. It's not a big deal, but I'm not going to approve removing the functions for the reasons above. If you disagree find someone else to get an approval.

@shinrich shinrich closed this Aug 6, 2021
@shinrich
Copy link
Member Author

shinrich commented Aug 6, 2021

I don't care much one way or the other. Just a tidy up PR anyway.

@zwoop zwoop modified the milestones: 10.0.0, 9.2.0 Sep 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants