Ignore:
Timestamp:
Oct 26, 2021, 4:27:10 PM (2 years ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
Children:
1733184
Parents:
2b30370
Message:

String performance improvements given hybrid design

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/containers/string_res.hfa

    r2b30370 r4e8df745  
    1717
    1818#include <fstream.hfa>
     19#include <string.h>    // e.g. strlen
    1920
    2021   
     
    7273// Constructors, Assignment Operators, Destructor
    7374void ?{}(string_res &s); // empty string
    74 void ?{}(string_res &s, const char* initial); // copy from string literal (NULL-terminated)
    7575void ?{}(string_res &s, const char* buffer, size_t bsize); // copy specific length from buffer
     76static inline void ?{}(string_res &s, const char* rhs) { // copy from string literal (NULL-terminated)
     77    (s){ rhs, strlen(rhs) };
     78}
    7679
    7780void ?{}(string_res &s, const string_res & s2) = void;
     
    8588
    8689void assign(string_res &s, const char* buffer, size_t bsize); // copy specific length from buffer
    87 void ?=?(string_res &s, const char* other); // copy from string literal (NULL-terminated)
     90static inline void ?=?(string_res &s, const char* other) {  // copy from string literal (NULL-terminated)
     91    assign(s, other, strlen(other));
     92}
    8893void ?=?(string_res &s, const string_res &other);
    8994void ?=?(string_res &s, string_res &other);
     
    97102
    98103// Concatenation
     104void append(string_res &s, const char* buffer, size_t bsize);
    99105void ?+=?(string_res &s, char other); // append a character
    100106void ?+=?(string_res &s, const string_res &s2); // append-concatenate to first string
    101 void ?+=?(string_res &s, const char* other);
    102 void append(string_res &s, const char* buffer, size_t bsize);
     107static inline void ?+=?(string_res &s, const char* other) {
     108    append( s, other, strlen(other) );
     109}
    103110
    104111// Character access
Note: See TracChangeset for help on using the changeset viewer.