Bug 119482 - Waste work in MediaController() and ArrayBuffer()
Summary: Waste work in MediaController() and ArrayBuffer()
Status: UNCONFIRMED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-04 19:14 PDT by Po-Chun Chang
Modified: 2014-03-03 16:53 PST (History)
3 users (show)

See Also:


Attachments
Suggested patch part 1 (820 bytes, patch)
2013-08-04 19:16 PDT, Po-Chun Chang
no flags Details | Formatted Diff | Diff
Suggested patch part 2 (581 bytes, patch)
2013-08-04 19:17 PDT, Po-Chun Chang
no flags Details | Formatted Diff | Diff
Suggested patch part 3 (552 bytes, patch)
2013-08-04 19:17 PDT, Po-Chun Chang
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Po-Chun Chang 2013-08-04 19:14:39 PDT
The problem appears in revision 153701. I have attached simple one-line patches that fixes it.

In method ustomFilterValidatedProgram::rewriteMixVertexShader() in WebCore/platform/graphics/filters/CustomFilterValidatedProgram.cpp, the loop on line 228 should break immediately after "texCoordAttributeDefined" is set to "true". All the iterations after "texCoordAttributeDefined" is set to "true" do not perform any useful work, at best they just set "texCoordAttributeDefined" again to "true".

Similarly, method MediaController::hasEnded() in WebCore/html/MediaController.cpp, the loop on line 528 should break immediately after "allHaveEnded" is set to "false". Method ArrayBuffer::transfer() in WTF/wtf/ArrayBuffer.cpp, the loop on line 46 should break immediately after "allViewsAreNeuterable" is set to "false".
Comment 1 Po-Chun Chang 2013-08-04 19:16:59 PDT
Created attachment 208105 [details]
Suggested patch part 1
Comment 2 Po-Chun Chang 2013-08-04 19:17:26 PDT
Created attachment 208106 [details]
Suggested patch part 2
Comment 3 Po-Chun Chang 2013-08-04 19:17:44 PDT
Created attachment 208107 [details]
Suggested patch part 3
Comment 4 Dirk Schulze 2014-03-02 10:31:46 PST
Custom shaders don't exist anymore. Is the bug still valid for the other two types? Removing custom shader text from title.
Comment 5 Eric Carlson 2014-03-03 16:53:44 PST
Comment on attachment 208106 [details]
Suggested patch part 2

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

> WebCore/html/MediaController.cpp:534
>      bool allHaveEnded = true;
>      for (size_t index = 0; index < m_mediaElements.size(); ++index) {
> -        if (!m_mediaElements[index]->ended())
> +        if (!m_mediaElements[index]->ended()) {
>              allHaveEnded = false;
> +            break;
> +        }
>      }
>      return allHaveEnded;

Actually, we can do away with the variable completely and just "return false" when the loop finds an element that hasn't ended, and "return true" if the loop completes.