Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
CPAN Release 0.02
- Modernize to Zilla::Dist
- Convert XS to Inline::Module
  • Loading branch information
ingydotnet committed Jan 2, 2015
1 parent c583950 commit f81d741
Show file tree
Hide file tree
Showing 10 changed files with 295 additions and 259 deletions.
6 changes: 6 additions & 0 deletions Changes
@@ -1,4 +1,10 @@
---
version: 0.02
date: Fri Jan 2 01:31:47 PST 2015
changes:
- Modernize to Zilla::Dist
- Convert XS to Inline::Module
---
version: 0.01
date: Tue Oct 16 00:02:29 PDT 2012
changes:
Expand Down
10 changes: 0 additions & 10 deletions Makefile.PL

This file was deleted.

30 changes: 30 additions & 0 deletions Meta
@@ -0,0 +1,30 @@
=meta: 0.0.1

name: String-Slice
version: 0.02
abstract: Shared Memory Slices of Bigger Strings
homepage: https://metacpan.org/release/String-Slice
license: perl
copyright: 2012-2015

author:
name: Ingy döt Net
email: ingy@cpan.org
github: ingydotnet
twitter: ingydotnet
freenode: ingy
homepage: http://ingy.net

requires:
perl: 5.8.1

devel:
git: https://github.com/ingydotnet/string-slice-pm
bug: https://github.com/ingydotnet/string-slice-pm/issues
irc: irc.perl.org#inline

badge: travis

=zild:
inline:
module: String::Slice
74 changes: 0 additions & 74 deletions README

This file was deleted.

93 changes: 93 additions & 0 deletions ReadMe.pod
@@ -0,0 +1,93 @@
=pod

=for comment
DO NOT EDIT. This Pod was generated by Swim v0.1.35.
See http://github.com/ingydotnet/swim-pm#readme

=encoding utf8

=head1 Name

String::Slice - Shared Memory Slices of Bigger Strings

=for html
<a href="https://travis-ci.org/ingydotnet/string-slice-pm"><img src="https://travis-ci.org/ingydotnet/string-slice-pm.png" alt="string-slice-pm"></a>

=head1 Synopsis

use String::Slice;

my $buffer = fetch_enormous_string;
my $slice;

# Make $slice reference chars 101-125 of $buffer
slice($slice, $buffer, 101, 25);

# Make $slice reference chars 126-175 of $buffer
slice($slice, $buffer, 25, 50);

# Make $slice reference chars 120 to end of $buffer
slice($slice, $buffer, -6);

# Look for $pattern in $buffer,
# at each 100 byte starting point
$slice = ''; # Reset $slice
for (my $i = 0; slice($slice, $buffer, $i); $i += 100) {
if ($slice =~ /^$pattern/) { ... do it ... }
}

=head1 Description

Processing large strings in Perl is inefficient because to access any smaller
portion of a buffer you need to make a copy of that portion.

This module lets you make a string scalar point to a portion of the content of
another string scalar.

The primary goal of this module is to make the parsing large data much
faster in Perl.

=head1 API

String::Slice exports one function: C<slice>. It can be called in a few
different ways:

slice($slice_variable, $big_buffer_variable, $char_offset, $char_length)

This effectively makes C<$slice_variable> a substr of the buffer. The offset
defaults to 0, and if no length is given, the slice goes to the end of the
buffer. One side effect of this function is that both strings will become
readonly, and the memory will not be freed until they both go out of scope.

If C<$slice> is already a slice of C<$buffer> then this call:

slice($slice, $buffer, $offset, $length)

will move the offset forward by the specified number (or backwards if the
offset is negative).

If length is too long, the slice will go to the end of the buffer.

The C<slice> function returns 1 on success and 0 on failure. Failure occurs if
the requested offset is invalid (less than the start or greater than or equal
to the end of the buffer).

=head1 Credit

Thanks go out to Jan Dubois and Florian Ragwitz for help on how to do
this right.

=head1 Author

Ingy döt Net <ingy@cpan.org>

=head1 Copyright and License

Copyright 2012-2015. Ingy döt Net.

This program is free software; you can redistribute it and/or modify it under
the same terms as Perl itself.

See L<http://www.perl.com/perl/misc/Artistic.html>

=cut
67 changes: 67 additions & 0 deletions doc/String/Slice.swim
@@ -0,0 +1,67 @@
<<<cpan-head>>>

= Synopsis

use String::Slice;

my $buffer = fetch_enormous_string;
my $slice;

# Make $slice reference chars 101-125 of $buffer
slice($slice, $buffer, 101, 25);

# Make $slice reference chars 126-175 of $buffer
slice($slice, $buffer, 25, 50);

# Make $slice reference chars 120 to end of $buffer
slice($slice, $buffer, -6);

# Look for $pattern in $buffer,
# at each 100 byte starting point
$slice = ''; # Reset $slice
for (my $i = 0; slice($slice, $buffer, $i); $i += 100) {
if ($slice =~ /^$pattern/) { ... do it ... }
}

= Description

Processing large strings in Perl is inefficient because to access any smaller
portion of a buffer you need to make a copy of that portion.

This module lets you make a string scalar point to a portion of the content of
another string scalar.

The primary goal of this module is to make the parsing large data much faster
in Perl.

= API

String::Slice exports one function: `slice`. It can be called in a few
different ways:

slice($slice_variable, $big_buffer_variable, $char_offset, $char_length)

This effectively makes `$slice_variable` a substr of the buffer. The offset
defaults to 0, and if no length is given, the slice goes to the end of the
buffer. One side effect of this function is that both strings will become
readonly, and the memory will not be freed until they both go out of scope.

If `$slice` is already a slice of `$buffer` then this call:

slice($slice, $buffer, $offset, $length)

will move the offset forward by the specified number (or backwards if the
offset is negative).

If length is too long, the slice will go to the end of the buffer.

The `slice` function returns 1 on success and 0 on failure. Failure occurs if
the requested offset is invalid (less than the start or greater than or equal
to the end of the buffer).

= Credit

Thanks go out to Jan Dubois and Florian Ragwitz for help on how to do this
right.

<<<cpan-tail>>>

0 comments on commit f81d741

Please sign in to comment.