Skip to content

Commit cd6e01b

Browse files
committed
[js] Implement nqp::x using String.repeat.
1 parent 36b8182 commit cd6e01b

File tree

2 files changed

+1
-8
lines changed

2 files changed

+1
-8
lines changed

src/vm/js/Operations.nqp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ class QAST::OperationsJS {
399399
add_simple_op('time_i', $T_NUM, [], sub () {"Math.floor(new Date().getTime() / 1000)"}, :sideffects);
400400

401401
add_simple_op('escape', $T_STR, [$T_STR]);
402-
add_simple_op('x', $T_STR, [$T_STR, $T_INT]);
402+
add_simple_op('x', $T_STR, [$T_STR, $T_INT], sub ($what, $times) {"$what.repeat($times)"});
403403

404404
add_simple_op('getcomp', $T_OBJ, [$T_STR], :sideffects);
405405

src/vm/js/nqp-runtime/core.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,6 @@ op.escape = function(str) {
4949
.replace(/"/g, '\\"');
5050
};
5151

52-
op.x = function(str, times) {
53-
if (!times) return '';
54-
var ret = str;
55-
while (--times) ret += str;
56-
return ret;
57-
};
58-
5952
function radixHelper(radix, str, zpos, flags) {
6053
var lowercase = 'a-' + String.fromCharCode('a'.charCodeAt(0) + radix - 11);
6154
var uppercase = 'A-' + String.fromCharCode('A'.charCodeAt(0) + radix - 11);

0 commit comments

Comments
 (0)