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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use Uint8List instead of List<int> #37

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

gcxfd
Copy link

@gcxfd gcxfd commented May 26, 2021

#36

Copy link
Owner

@simolus3 simolus3 left a comment

Choose a reason for hiding this comment

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

Thanks! I think we should also change allocateBytes to only accept an Uint8List. Currently it copies the data it gets to a new Uint8List, we can avoid that copy if we get an Uint8List in the first place.

@@ -69,6 +69,8 @@ extension ValueUtils on Pointer<sqlite3_value> {
}
}

final utf8Encode = utf8.encoder.convert;
Copy link
Owner

Choose a reason for hiding this comment

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

I think we should only define this once, the usage in memory.dart can just import this one.

@@ -3,7 +3,7 @@ import 'package:meta/meta.dart';
/// A scalar function exposed to sql.
///
/// {@template sqlite3_function_behavior}
/// The function must either return a `bool`, `num`, `String`, `List<int>` or
/// The function must either return a `bool`, `num`, `String`, `Uint8List` or
Copy link
Owner

Choose a reason for hiding this comment

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

I don't think we should force users to return a Uint8List here. It's a breaking change which IMO is not necessary. Most users return a Uint8List already, I don't see much value in an enforcement in the type system.

We can check if we got an Uint8List and implicitly copy to an Uint8List if we didn't.

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

Successfully merging this pull request may close these issues.

2 participants