Skip to content

Implemented string_view type#103

Draft
Krzychuo wants to merge 2 commits into
Operacja-System:mainfrom
Krzychuo:string-view
Draft

Implemented string_view type#103
Krzychuo wants to merge 2 commits into
Operacja-System:mainfrom
Krzychuo:string-view

Conversation

@Krzychuo
Copy link
Copy Markdown

No description provided.

@Kamilosok Kamilosok added the new feature Added new functionality label Apr 28, 2026
Comment thread include/stdbigos/string_view.h Outdated
size_t count;
} string_view;

static inline string_view strv_init(const char* str) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Names of functions that acting as methods for a structs should start with the full name of the struct

Comment thread include/stdbigos/string_view.h Outdated

static inline string_view strv_init(const char* str) {
if (!str)
return (string_view){NULL, 0};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use nullptr instead of NULL

Comment thread include/stdbigos/string_view.h Outdated
i++;
}

ret.count = (size_t)(i - str);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use strlen from stdbigos/string.h

Comment thread include/stdbigos/string_view.h Outdated
return ret;
}

static inline size_t strvlen(string_view strv) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this function is necessary

Comment thread include/stdbigos/string_view.h Outdated

static inline int strvncmp(string_view a, string_view b, size_t n) {
size_t min = a.count < b.count ? a.count : b.count;
if (min > n)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use MIN(a, b) from math.h

Comment thread include/stdbigos/string_view.h Outdated
return strv;
}

static inline string_view strvtok(string_view strv, string_view delim) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't abbreviate names unnecessarily. Naming this like string_view_tokenise would be better imo. Also I think this function would be easier to use if it took a string view by reference so that returned string view has the token and the one taken as reference would have the rest of the string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new feature Added new functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants