Bug 127003 - MediaSessionManager shouldn't use std::map
Summary: MediaSessionManager shouldn't use std::map
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Eric Carlson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-14 13:26 PST by Eric Carlson
Modified: 2014-01-15 19:36 PST (History)
4 users (show)

See Also:


Attachments
Proposed patch (4.22 KB, patch)
2014-01-14 13:30 PST, Eric Carlson
sam: review-
Details | Formatted Diff | Diff
Another patch. (3.30 KB, patch)
2014-01-15 17:21 PST, Eric Carlson
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Carlson 2014-01-14 13:26:27 PST
Just don't do it!
Comment 1 Eric Carlson 2014-01-14 13:30:01 PST
Created attachment 221195 [details]
Proposed patch
Comment 2 Sam Weinig 2014-01-14 18:01:08 PST
Comment on attachment 221195 [details]
Proposed patch

View in context: https://bugs.webkit.org/attachment.cgi?id=221195&action=review

> Source/WebCore/platform/audio/MediaSessionManager.h:71
> +    typedef HashMap<MediaSession::MediaType, SessionRestrictions, WTF::IntHash<unsigned>, WTF::HashTraits<unsigned>> RestrictionsMap;

I think you can actually do much better than a HashMap.  How about something like an array of SessionRestrictions of size == LagestValueOfMediaType + 1:

SessionRestrictions[WebAudio + 1];

But, if you use the HashMap, you need to use traits that allow for a 0 value key (e.g. UnsignedWithZeroKeyHashTraits).
Comment 3 Eric Carlson 2014-01-15 17:21:00 PST
Created attachment 221320 [details]
Another patch.
Comment 4 Sam Weinig 2014-01-15 18:51:57 PST
Comment on attachment 221320 [details]
Another patch.

Nice.
Comment 5 Eric Carlson 2014-01-15 19:09:51 PST
(In reply to comment #4)
> (From update of attachment 221320 [details])
> Nice.

Thanks for the suggestion, my first and second versions were definitely over engineered :-)
Comment 6 WebKit Commit Bot 2014-01-15 19:36:19 PST
Comment on attachment 221320 [details]
Another patch.

Clearing flags on attachment: 221320

Committed r162108: <http://trac.webkit.org/changeset/162108>
Comment 7 WebKit Commit Bot 2014-01-15 19:36:22 PST
All reviewed patches have been landed.  Closing bug.