jenkins-bot has submitted this change and it was merged.
Change subject: Prefer test() and simplify regular expressions for performance
......................................................................
Prefer test() and simplify regular expressions for performance
Change-Id: I3c1a9d8830ad477b5ff857a7c98eb68b26ded698
---
M wikibase/queryService/api/QuerySamples.js
M wikibase/queryService/api/Sparql.js
M wikibase/queryService/ui/editor/hint/Sparql.js
M wikibase/queryService/ui/resultBrowser/helper/FormatterHelper.js
4 files changed, 6 insertions(+), 13 deletions(-)
Approvals:
Jonas Kress (WMDE): Looks good to me, approved
jenkins-bot: Verified
diff --git a/wikibase/queryService/api/QuerySamples.js
b/wikibase/queryService/api/QuerySamples.js
index db8f0fb..e5bc4d3 100644
--- a/wikibase/queryService/api/QuerySamples.js
+++ b/wikibase/queryService/api/QuerySamples.js
@@ -55,7 +55,7 @@
SELF.prototype._extract = function ( wikitext ) {
var self = this,
examples = [],
- regexSection = /^\=\=([^\=]+)\=\=$/g,
+ regexSection = /^==([^=]+)==$/gm,
section = '',
sectionHeader = null;
diff --git a/wikibase/queryService/api/Sparql.js
b/wikibase/queryService/api/Sparql.js
index a88ee10..c46772d 100644
--- a/wikibase/queryService/api/Sparql.js
+++ b/wikibase/queryService/api/Sparql.js
@@ -232,7 +232,7 @@
*/
SELF.prototype._encodeCsv = function( string ) {
var result = string.replace( /"/g, '""' );
- if ( result.search( /("|,|\n)/g ) >= 0 ) {
+ if ( /[",\n]/.test( result ) ) {
result = '"' + result + '"';
}
return result;
diff --git a/wikibase/queryService/ui/editor/hint/Sparql.js
b/wikibase/queryService/ui/editor/hint/Sparql.js
index 8a744c2..3724694 100755
--- a/wikibase/queryService/ui/editor/hint/Sparql.js
+++ b/wikibase/queryService/ui/editor/hint/Sparql.js
@@ -88,7 +88,7 @@
SELF.prototype._getDefinedVariables = function( text ) {
var variables = {};
- $.each( text.match( /\?[\w]+/g ), function( key, word ) {
+ $.each( text.match( /\?\w+/g ), function( key, word ) {
variables[ word ] = true;
} );
@@ -135,7 +135,7 @@
pos = 0;
}
- while ( line.charAt( pos ).match( /[\w?#]/ ) ) {
+ while ( /[\w?#]/.test( line.charAt( pos ) ) ) {
pos--;
if ( pos < 0 ) {
break;
@@ -144,7 +144,7 @@
var left = pos + 1;
pos = position;
- while ( line.charAt( pos ).match( /[\w]/ ) ) {
+ while ( /\w/.test( line.charAt( pos ) ) ) {
pos++;
if ( pos >= line.length ) {
break;
diff --git a/wikibase/queryService/ui/resultBrowser/helper/FormatterHelper.js
b/wikibase/queryService/ui/resultBrowser/helper/FormatterHelper.js
index fe3cccd..183a3e8 100644
--- a/wikibase/queryService/ui/resultBrowser/helper/FormatterHelper.js
+++ b/wikibase/queryService/ui/resultBrowser/helper/FormatterHelper.js
@@ -230,15 +230,8 @@
if ( !this.isCommonsResource( url ) ) {
return url;
}
- if ( !width ) {
- width = 400;
- }
- if ( url.match( /^http\:\/\//i ) ) {
- url = url.replace( /^http\:\/\//, 'https://' );
- }
-
- return url + '?width=' + width;
+ return url.replace( /^http(?=:\/\/)/, 'https' ) + '?width=' + (
width || 400 );
};
/**
--
To view, visit https://gerrit.wikimedia.org/r/304005
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3c1a9d8830ad477b5ff857a7c98eb68b26ded698
Gerrit-PatchSet: 1
Gerrit-Project: wikidata/query/gui
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: Jonas Kress (WMDE) <[email protected]>
Gerrit-Reviewer: Smalyshev <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits