@@ -262,9 +262,9 @@ class Token
262
262
{}
263
263
264
264
// Token constructor from token id, location, and a string.
265
- Token (TokenId token_id, Location location, const std::string ¶mStr)
266
- : token_id (token_id), locus (location), str ( new std::string (paramStr)),
267
- type_hint (CORETYPE_UNKNOWN)
265
+ Token (TokenId token_id, Location location, std::string & ¶mStr)
266
+ : token_id (token_id), locus (location),
267
+ str ( new std::string (std::move (paramStr))), type_hint (CORETYPE_UNKNOWN)
268
268
{}
269
269
270
270
// Token constructor from token id, location, and a char.
@@ -281,10 +281,10 @@ class Token
281
281
{}
282
282
283
283
// Token constructor from token id, location, a string, and type hint.
284
- Token (TokenId token_id, Location location, const std::string ¶mStr,
284
+ Token (TokenId token_id, Location location, std::string & ¶mStr,
285
285
PrimitiveCoreType parType)
286
- : token_id (token_id), locus (location), str ( new std::string (paramStr)),
287
- type_hint (parType)
286
+ : token_id (token_id), locus (location),
287
+ str ( new std::string (std::move (paramStr))), type_hint (parType)
288
288
{}
289
289
290
290
public:
@@ -311,34 +311,37 @@ class Token
311
311
}
312
312
313
313
// Makes and returns a new TokenPtr of type IDENTIFIER.
314
- static TokenPtr make_identifier (Location locus, const std::string &str)
314
+ static TokenPtr make_identifier (Location locus, std::string & &str)
315
315
{
316
316
// return std::make_shared<Token> (IDENTIFIER, locus, str);
317
- return TokenPtr (new Token (IDENTIFIER, locus, str));
317
+ return TokenPtr (new Token (IDENTIFIER, locus, std::move ( str) ));
318
318
}
319
319
320
320
// Makes and returns a new TokenPtr of type INT_LITERAL.
321
- static TokenPtr make_int (Location locus, const std::string &str,
321
+ static TokenPtr make_int (Location locus, std::string & &str,
322
322
PrimitiveCoreType type_hint = CORETYPE_UNKNOWN)
323
323
{
324
324
// return std::make_shared<Token> (INT_LITERAL, locus, str, type_hint);
325
- return TokenPtr (new Token (INT_LITERAL, locus, str, type_hint));
325
+ return TokenPtr (
326
+ new Token (INT_LITERAL, locus, std::move (str), type_hint));
326
327
}
327
328
328
329
// Makes and returns a new TokenPtr of type FLOAT_LITERAL.
329
- static TokenPtr make_float (Location locus, const std::string &str,
330
+ static TokenPtr make_float (Location locus, std::string & &str,
330
331
PrimitiveCoreType type_hint = CORETYPE_UNKNOWN)
331
332
{
332
333
// return std::make_shared<Token> (FLOAT_LITERAL, locus, str, type_hint);
333
- return TokenPtr (new Token (FLOAT_LITERAL, locus, str, type_hint));
334
+ return TokenPtr (
335
+ new Token (FLOAT_LITERAL, locus, std::move (str), type_hint));
334
336
}
335
337
336
338
// Makes and returns a new TokenPtr of type STRING_LITERAL.
337
- static TokenPtr make_string (Location locus, const std::string &str)
339
+ static TokenPtr make_string (Location locus, std::string & &str)
338
340
{
339
341
// return std::make_shared<Token> (STRING_LITERAL, locus, str,
340
342
// CORETYPE_STR);
341
- return TokenPtr (new Token (STRING_LITERAL, locus, str, CORETYPE_STR));
343
+ return TokenPtr (
344
+ new Token (STRING_LITERAL, locus, std::move (str), CORETYPE_STR));
342
345
}
343
346
344
347
// Makes and returns a new TokenPtr of type CHAR_LITERAL.
@@ -356,17 +359,17 @@ class Token
356
359
}
357
360
358
361
// Makes and returns a new TokenPtr of type BYTE_STRING_LITERAL (fix).
359
- static TokenPtr make_byte_string (Location locus, const std::string &str)
362
+ static TokenPtr make_byte_string (Location locus, std::string & &str)
360
363
{
361
364
// return std::make_shared<Token> (BYTE_STRING_LITERAL, locus, str);
362
- return TokenPtr (new Token (BYTE_STRING_LITERAL, locus, str));
365
+ return TokenPtr (new Token (BYTE_STRING_LITERAL, locus, std::move ( str) ));
363
366
}
364
367
365
368
// Makes and returns a new TokenPtr of type LIFETIME.
366
- static TokenPtr make_lifetime (Location locus, const std::string &str)
369
+ static TokenPtr make_lifetime (Location locus, std::string & &str)
367
370
{
368
371
// return std::make_shared<Token> (LIFETIME, locus, str);
369
- return TokenPtr (new Token (LIFETIME, locus, str));
372
+ return TokenPtr (new Token (LIFETIME, locus, std::move ( str) ));
370
373
}
371
374
372
375
// Gets id of the token.
0 commit comments