Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove duplicate bufferIntersection code #880

Merged
merged 2 commits into from
Jun 25, 2020

Conversation

brandonocasey
Copy link
Contributor

No functional change here. This refactor removes util/buffer the nearly identical function in ranges.js. While trying to find out why we sometimes download duplicate segments I cam upon a solution that used bufferIntersection. Thats when I noticed that these functions are doing the same thing, and util/buffer is just a copy paste.

@@ -4,7 +4,7 @@
import videojs from 'video.js';
import logger from './util/logger';
import noop from './util/noop';
import { buffered } from './util/buffer';
import { bufferIntersection } from './ranges.js';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the one in ranges

@@ -322,7 +322,15 @@ export default class SourceUpdater extends videojs.EventTarget {
}

buffered() {
return buffered(this.videoBuffer, this.audioBuffer);
if (this.audioBuffer && !this.videoBuffer) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only unique functionality in that file what using audio or video buffered, if we only had a buffer for one or the other.

@brandonocasey brandonocasey force-pushed the refactor/remove-buffered branch 2 times, most recently from 90a856c to 9a18a20 Compare June 25, 2020 19:14

QUnit.module('buffer');

QUnit.test('buffered returns video buffered when no audio', function(assert) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First two tests here moved to sourceUpdater, the rest moved to ranges.

@brandonocasey brandonocasey force-pushed the refactor/remove-buffered branch from 9a18a20 to b6df38b Compare June 25, 2020 19:21
@@ -4,7 +4,7 @@
import videojs from 'video.js';
import logger from './util/logger';
import noop from './util/noop';
import { buffered } from './util/buffer';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds like we can delete buffer.js?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woops, removing

@brandonocasey brandonocasey merged commit 0ca43bd into main Jun 25, 2020
@gkatsev gkatsev deleted the refactor/remove-buffered branch June 26, 2020 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants