Skip to content

Commit

Permalink
Update substr calls to substring (#4276)
Browse files Browse the repository at this point in the history
* Update substr calls to substring

* const -> var
  • Loading branch information
willeastcott authored May 31, 2022
1 parent 599355a commit f6ec317
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/graphics/program-lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function collectAttribs(vsCode) {
if (found > 0 && vsCode[found - 1] === "/") break;
const endOfLine = vsCode.indexOf(';', found);
const startOfAttribName = vsCode.lastIndexOf(' ', endOfLine);
const attribName = vsCode.substr(startOfAttribName + 1, endOfLine - (startOfAttribName + 1));
const attribName = vsCode.substring(startOfAttribName + 1, endOfLine);

const semantic = attrib2Semantic[attribName];
if (semantic !== undefined) {
Expand Down
2 changes: 1 addition & 1 deletion src/graphics/shader-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ShaderInput {
this.version = new Version();

// custom data type for arrays
if (name.substr(name.length - 3) === "[0]") {
if (name.substring(name.length - 3) === "[0]") {
switch (type) {
case UNIFORMTYPE_FLOAT: type = UNIFORMTYPE_FLOATARRAY; break;
case UNIFORMTYPE_VEC2: type = UNIFORMTYPE_VEC2ARRAY; break;
Expand Down
5 changes: 3 additions & 2 deletions src/polyfill/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ defineProtoFunc(String, 'includes', function(search, start) {
});

// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith#Polyfill
defineProtoFunc(String, 'startsWith', function(search, pos) {
return this.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
defineProtoFunc(String, 'startsWith', function(search, rawPos) {
var pos = rawPos > 0 ? rawPos|0 : 0;
return this.substring(pos, pos + search.length) === search;
});
10 changes: 5 additions & 5 deletions src/resources/untar.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ function UntarScope(isWorker) {
const headers = asciiDecoder.decode(headersDataView);
this._bytesRead += 512;

let name = headers.substr(0, 100).replace(/\0/g, '');
const ustarFormat = headers.substr(257, 6);
const size = parseInt(headers.substr(124, 12), 8);
const type = headers.substr(156, 1);
let name = headers.substring(0, 100).replace(/\0/g, '');
const ustarFormat = headers.substring(257, 263);
const size = parseInt(headers.substring(124, 136), 8);
const type = headers.substring(156, 157);
const start = this._bytesRead;
let url = null;

Expand Down Expand Up @@ -171,7 +171,7 @@ function UntarScope(isWorker) {
}

if (ustarFormat.indexOf('ustar') !== -1) {
const namePrefix = headers.substr(345, 155).replace(/\0/g, '');
const namePrefix = headers.substring(345, 500).replace(/\0/g, '');

if (namePrefix.length > 0) {
name = namePrefix.trim() + name.trim();
Expand Down

0 comments on commit f6ec317

Please sign in to comment.