If "otherOrigin == this" in SecurityOrigin::equal, it's obviously equal.
> SecurityOrigin was created to cleanup the way we do same-origin checks in
> relaxing). The main design constraint then was that it was a cheap compare
> for two origins representing the same document (pointer compare) as that is
> common case. The code evolved from there.
Makes sense. Note that SecurityOrigin::equal does not currently do a fast
path check of "this == other" (to just do a pointer compare as you
mentioned) so this is probably low hanging fruit to make things a bit
faster. (Though, as you said, it's not showing up on current profiles...so
it's probably not a huge deal.)
Created attachment 30937 [details]
Wouldn't it makes more sense to do this in isSameSchemeHostPort?
I don't think so. I only see isSameSchemeHostPort used a couple places, but they don't seem like they'd benefit from such an optimization . ::equal, on the other hand, is called pretty often (it's used a lot in hash tables). It seems a bit painful to require another function call plus a branch or two for a function that's not called very often.
We could put the == check in both places. Doing one additional branch isn't going to hurt the slow path. It doesn't seem necessary though.
Comment on attachment 30937 [details]
Seems fine. r=me
Assign for landing.
Landed in @r44420.