Re: [PATCH] - improved decoding of URL special characters
Dustin Kirkland <[email protected]> Thu, 20 Oct 2005 09:01:11 -0400
| Newsgroups | gmane.comp.multimedia.xmms.devel |
|---|---|
| Message-ID | <[email protected]> |
On 10/19/05, Andrew Sveikauskas <[email protected]> wrote: > On Wed, Oct 19, 2005 at 04:20:37PM -0500, Dustin Kirkland wrote: > > I think it's a matter of taste, and I don't particularly care if my > > patch or yours (I assume a patch would come along) were eventually > > accepted. I'd just like to see this functionality at some point in > > the mainline xmms ;) > > You're right, it really doesn't matter. I just thought I'd throw my two cents > in. > > To be honest I'm a bit too occupied at the moment to come up with a patch and > try it out. With your permission, I'll create a patch from your code and submit it into this thread. > I guess it didn't show up in your test but the point about performance is that > it would appear that, let's say the string was %ff%ff%ff%ff%ff etc. If I am > reading it correctly, your version would take the first %ff, put the byte 255 > at the beginning, and move the rest of the string to the start, then do the > whole thing over again for the next %ff, copying the remaining portion of the > string again and again. Mine loops through the characters exactly once > regardless of input. > > But again, in practical terms it's not noticable. Maybe I'm reading your code > wrong, even. That's basically it. But it doesn't start at the beginning everytime. If you look at cur = hexstr + 1 .... str = cur, that guaratees that every subsequent iteration of the loop is only looking at the string beyond the last replaced %xx. But once those 3 chars are replaced with the 1 intended, it move the entire string backwards 2 positions. I basically just recycled the existing code that XMMS was using to replace the %20's with whitespace. I think that yours is probably more efficient in that each character examined is moved at most once, and the excess in your string exists beyond the null byte string terminator. In which case stating that the goal of this patch is "improved decoding of URL special characters", I'll concede that your function likely improves it better ;) I'll test and submit a patch based on your function if you don't have time and that's ok by you. -- XMMS maintainers: Is this something that you're interested in picking up? It's a minor annoyance, but it's easily observable in any existing release of XMMS, and it's trivially fixed by these patchs? -- :-Dustin