Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pattern matching in node_type #194

Closed
RustemB opened this issue May 24, 2021 · 8 comments
Closed

Pattern matching in node_type #194

RustemB opened this issue May 24, 2021 · 8 comments

Comments

@RustemB
Copy link

RustemB commented May 24, 2021

for exampe

xplr.config.node_types.mime_essence = {
	["video/*"] = {
		meta = { icon = "馃摻" },
	}
}

to match all video types

@sayanarijit
Copy link
Owner

Pattern matching might be a little difficult to implement and might have performance costs. But I think it'll be possible to implement nested mime types.

E.g.

video = {
  default = ...
  mp4 = ...
}

@bew
Copy link

bew commented May 24, 2021

I'm curious, what would be difficult to implement here?

As for performance, have you considered a cache, to search only once the settings for a given mime type, and always use the same on subsequent needs?

@sayanarijit
Copy link
Owner

sayanarijit commented May 24, 2021

Going through the keys and matching patterns efficiency.

From O(1) it becomes O(n)

@sayanarijit
Copy link
Owner

sayanarijit commented May 24, 2021

I'm curious, what would be difficult to implement here?

As for performance, have you considered a cache, to search only once the settings for a given mime type, and always use the same on subsequent needs?

Sounds cool. Can you please provide a minimal prototype implementation for xplr?

@bew
Copy link

bew commented May 24, 2021

Not anytime soon, I'm a Rust beginner who happen to have a few ideas from times to times, but not enough time to do them ATM. 馃憖

My comment was mainly to give an idea in case you didn't thought about it, but I won't contribute code for now

@sayanarijit
Copy link
Owner

No issues 馃憤
And thanks for the suggestion. I'll keep it in mind.

@sayanarijit
Copy link
Owner

sayanarijit commented May 25, 2021

Going with the no-pattern matching logic.

You can defing mime types like

xplr.config.node_types.mime_essence["video"] = {
  ["*"] = {
    meta = { icon = "馃摻" },
  }
}

@sayanarijit
Copy link
Owner

I think the issue is solved. Hence closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants